Tactical changes by the respective managers, Jackie McNamara and Danny Lennon, turned this game on its head as Dundee United, 2-0 down at half-time, scored three times in the last 11 minutes to take all three points.
The visitors capitulated after Lennon's early second-half reshuffle, while McNamara's substitutions helped bring life to United whose late comeback ensured they will finish in the top six of the SPFL Premiership.
The Paisley team controlled the game for close to an hour and led through strikes from Paul McGowan and Steven Thompson, which underlined the ease with which Paisley side controlled the game for the opening hour.
Loading article content
Then Lennon replaced his right-back Jason Naismith with Gregg Wylde and moved Josh Magennis into defence. It was a move that was to prove catastrophic for St Mirren as United's Gary Mackay-Steven switched into turbo-drive and proceeded to run the Northern Ireland international ragged, playing a huge part in the Tannadice side's revival.
Add to the equation, the introduction by McNamara of Stuart Armstrong for a weary Ryan Gauld, and Ryan Dow for an ineffective Farid El Alagui, and the pieces that brought about an astonishing victory for the Tangerines fell into place.
Brian Graham, another substitute, scored their first goal and Armstrong added the equaliser before a remarkable injury-time strike from Nadir Ciftci, who somehow squeezed his shot in at the near post after St Mirren goalkeeper Marian Kello blundered in failing to hold Dow's stinging shot from distance.
McNamara said: "I was pleased with the spirit of the team in getting back to 2-2 and then pushing for the winner, but I thought we were very lucky to get it.
"I had always planned to make changes to the team. I wanted to give Gauld an hour and I knew the game would be stretched at that point.
"St Mirren were excellent in the first half and didn't give us the chance to do anything, but I knew they wouldn't be able to sustain it for the 90 minutes."
Lennon's side stormed into the lead after 20 minutes, aided by poor communication between United goalkeeper Radoslaw Cierzniak and teenage centre-back John Souttar. Marc McAusland's free-kick from inside his own half allowed McGowan a run into the area and, as Souttar and Cierzniak looked on, his back header floated over Pole and into the net.
The goal was indicative of St Mirren's superiority at this stage, with McGowan running the show in a stellar performance, while United looked lethargic and hesitant in defence.
When John McGinn beat Keith Watson on the left five minutes from the interval and Gavin Gunning attempted to clear, the ball cannoned off Thompson and into the United goal.
United's only significant chance of an entertaining first half arrived just seconds before the break, but El Alagui's volley was off target.
Ciftci burst towards the St Mirren goal at the start of the second half, only to over-run the ball, but it was a sign of a change of attitude, although McGowan's touch from Thompson's cross minutes later went close enough to re-engage the home side's defensive concerns.
However, their need to show their supporters something meaningful encouraged them to adopt a more direct approach and when Mackay-Steven forced Kello into an acrobatic save with a sizzling 22-yard strike, it signalled a renaissance that bore fruit after 79 minutes as Ciftci and Dow collaborated to set up Graham for a tap-in.
United's determination and resilience were further rewarded five minutes later when Mackay-Steven beat Magennis and crossed for Armstrong to finish from close range.
Then, with the clock past 90 minutes and the visitors probably pleased by then to have finished - they thought - with a point, came the killer blow.
Kello spilled Dow's strike and the ever-persistent Ciftci took control and hit the winner.
"Marian is a top-class keeper," Lennon said. "He didn't let anyone down. We've all taken it badly, but when goalkeepers make a massive error then it is highly documented. We won't chuck it. We'll get back in there and make sure we get going in the right manner again."