Lee Mair scored in stoppage time against doughty Hamilton Accies to take St Mirren into the quarter-finals of the Scottish Communities League Cup.
There wasn't much for either side's fans to cheer about in a goalless first half in Paisley.
Chances weren't forthcoming for most of the second 45 and, with two minutes of added time, extra-time loomed.
But Mair latched onto a corner from Graham Carey to guide the ball past goalkeeper Kevin Cuthbert.
The Buddies should have broken that deadlock as early as the opening minute, when Kenny McLean burst into the box only to drag his shot just wide of the upright.
Hamilton also should have opened the scoring when Louis Longridge raced on to a James Keatings ball and sent his effort fizzing across the face of goal and wide when he should have hit the target.
St Mirren were threatening again when what appeared to be a harmless cross come shot from Dougie Imrie took a major deflection and a full-stretch Cuthbert was called into action to tip just over.
Home manager Danny Lennon made his first change 10 minutes before the break when Lewis Guy was replaced by Thompson, with it unclear whether the substitution was down to injury or not.
With the tie still deadlocked at half-time following a fairly drab first half, the Buddies made another switch for the second half, with McLean making way for David van Zanten.
Jim Goodwin could have sparked the match into life shortly after the restart but sent his angled drive blazing over the bar instead as both sides struggled to find the opener.
The Buddies looked slightly more threatening in front of goal and a thunderous 25-yard free-kick from Carey forced an impressive save from Cuthbert.
Accies' goalkeeper came to the rescue again moments later, this time to tip a close-range header from Carey past the post as the home side pushed for a late winner.
St Mirren's pressure finally paid off deep into injury time when Mair threw himself in front of Carey's corner and his header found the back of the net with seconds to go.
St Mirren manager Danny Lennon : "We're delighted. It was a very hard obstacle Hamilton put in front of us.
"They had a very good organised set-up and great energy within their team.
"It was like chopping down a big old oak tree. We kept chopping and chopping and chopping and finally, on the last swing, it collapsed and we got the goal.
"We've got to another quarter-final and hopefully we can take it one step further."
Hamilton Academical manager Billy Reid : "I can't be negative on anything to be honest with you.
"We set out with a purpose of how we were going to play and I thought we were brilliant in the first half and were the better side.
"Some of our passing was absolutely magic. We were miles better in the first half and should have scored.
"They changed their formation a bit in the second half and we couldn't keep the ball as much and they bombarded us with long balls into the box.
"We dealt with almost everything and then lost the goal with the last kick of the ball. But it's all plusses for us."
Sorry, we were unable to load match stats, please try again.