Lancashire took Surrey's 10 wickets for just 88 runs to set up a victory target of 176 after Mark Stoneman had given the visitors an excellent start to the day.
It looked as though victory would be completed on day three as Livingstone's fifty took Lancashire to within 44 runs of the win, but bad light intervened to force the game into the final day.
The morning session mirrored day two in as much as a strong start by the batting side was undone by a flurry of wickets before lunch.
Surrey resumed on 79 without loss with a lead of 12 and Stoneman and Rory Burns went on to share a 150-run stand for the opening wicket.
Stoneman celebrated his call-up to the Ashes squad by racing to 98 from 113 balls before his wicket, taken by Livingstone, triggered a collapse by the visitors.
Stephen Parry dismissed the other set batsman Burns for 45 before Livingstone went on to claim career-best bowling figures.
He removed Scott Borthwick for four and Ben Foakes, another Ashes squad member, for a golden duck with successive deliveries to mean that Surrey had lost four wickets in 12 balls for just six runs.
The flow of wickets just continued before lunch with Olly Pope (three) and Rikki Clarke (13) both joining the list of victims claimed by Livingstone - and Sam Curran departing first ball to Stephen Parry.
At lunch Surrey were 197 for seven, leading by 130 with Kumar Sangakkara, playing in his last first-class game, still at the crease.
He received a guard of honour from Lancashire's players on his arrival and he went on to add 44 for the eighth wicket with Gareth Batty as Surrey attempted to respond to that flurry of wickets.
But the last three wickets fell in the space of six balls. Livingstone claimed his sixth as Batty chipped one high back to the bowler and Parry proceeded to remove Stuart Meaker and Jade Dernbach - both without scoring.
Surrey had slipped from 154 without loss to 242 all out, leaving Lancashire that chase of 176. Sangakkara, in his last first-class game, was unbeaten on 35.
Lancashire started their chase well, progressing to 40 for one when Alex Davies fell for a classy 30.