There were 89 minutes on the clock when Flynn slid in following a good Liam Kelly save to send the Simple Digital Arena into raptures for perhaps the first time this season.
The victory moves the Buddies onto 17 points, just one behind fellow relegation rivals Dundee and four behind Hamilton.
It could have been a different story for the visitors, who made a positive start amid gusty conditions.
They were presented with a golden opportunity when Buddies keeper Vaclav Hladky fumbled Keaghan Jacob’s delivery.
The ball arrived out of the ruck of players and found Chris Erskine - last week’s hero in the win over Kilmarnock - but he blazed over from point-blank range.
Steven Lawless then fired a volley well wide of the post amid a flurry of Livi corners, before the hosts began to put their stamp on a scrappy first half.
Seventeen-year-old wing-back Ethan Erhahon, a bright spark in an otherwise bleak season for the Buddies, did well to work some space down the left-hand side before feeding the ball through for the lively Duckens Nazon.
The forward broke clear but his left-footed strike was deflected wide by the boot of Kelly for a Saints corner.
Gary Holt’s visitors were not exactly at their free-flowing best in the testing conditions but they did carve out a couple of decent openings on a day when better finishing could have secured them a third successive victory over their opponents.
Craig Sibbald and Erskine both fired wildly off target when they should have made Hladky work while Craig Halkett’s speculative free-kick was better, but also failed to test the Czech in the Saints goal.
Then the moment of glory for Flynn and the Buddies arrived. Livi were caught up the pitch and substitute Simeon Jackson broke into the space. He looked to have run into a dead end but managed to manoeuvre the space to let rip with his left foot.
His fierce strike was parried away well by Kelly but Flynn was on hand as he slid in at the back post to knock the ball into the net for his first goal in over a year.