Playmaker Connor Ronan sealed his timely return from suspension with a dramatic late winner to give St Mirren's top six hopes a serious boost.
The Buddies knew they had the perfect chance to fire themselves firmly into the mix for a top half finish against Premiership strugglers Dundee.
They spurned the best opportunity in the first half when Wigan loanee Jordan Jones failed to make the most of an excellent chance with Dee keeper Harrison Sharp off his line.
The Saints were far from their best but again produced the best opening in the second half, with the ball breaking to Jones on the edge of the six yard box.
This time the winger blazed wastefully over the bar, with Eamonn Brophy and Jones also going agonisingly close in the dying stages.
It looked like Stephen Robinson's wait for a first win was set to continue, but up stepped Ronan to head in the crucial opener from substitute Jay Henderson's pinpoint cross to seal all three points in extra-time.
The victory is a major morale-booster ahead of Saturday's trip to face Hearts in their Scottish Cup quarter-final clash.
Robinson reverted to a back four, much to the delight of the Saints fans who were calling for the tactical switch ahead of kick-off.
Connor Ronan was back in the starting XI having served his suspension for a red card, while Eamonn Brophy was fit enough to start his first match since he went off injured against Motherwell at the start of February.
The Buddies looked to have taken Robinson's demands on board to pass the ball more than in his opening three matches, with the visitors looking to play their way through the lines in the opening 10 minutes.
Unfortunately there were far too many that didn't hit their mark, with Dundee often picking up possession fairly cheaply.
The hosts' Max Anderson had the first effort of the evening, with his shot from the edge of the box blocked away to safety by Alex Gogic.
Saints almost broke through the home defence when Brophy's clever flick sent Greg Kiltie racing in on goal.
Dee keeper Harrison Sharp was off his line smartly to collect, with Kiltie requiring treatment after colliding with the stopper.
It was a turgid affair in the opening 30 minutes, with neither side able muster the quality to cut the other open.
Jordan Jones wasn't involved enough for the travelling supporters' liking, but the talented winger spurned a glorious opportunity to open the scoring.
A ball through the middle caught Dundee keeper Sharp short, with the Wigan loanee failing to put enough on his lob attempt to break the deadlock when he really should have done better.
St Mirren were threatening to come to life as half-time loomed, with Kiltie doing brilliantly on the right wing before cutting back for Brophy just before the ball ran out of play.
Unfortunately for the away side his close-range effort was blocked by Zeno Ibsen Rossi.
Dundee skipper Jordan McGhee then blasted an effort over the bar after some nice link-up play as the game finally started to heat up.
The second half began with a yellow card for the Saints as Richard Tait was booked for a mistimed challenge.
Dundee then went close to opening the scoring when a superb Niall McGinn cross into the box eventually fell to Declan McDaid. His effort was crucially blocked just over the bar by Joe Shaughnessy.
The home side were on top and looked the more likely to trouble the scoresheet.
But it was the Saints who spurned yet another glorious chance at the other end.
A superb Ronan pass found Tait on the wing in space, who played Kiltie into the box first-time.
The ball first broke to Brophy, who saw two efforts blocked, before bobbling into the path of Jones. With the goal at his mercy the winger blazed wastefully into the Saints fans behind the net.
Those supporters were screaming for a penalty shortly after when a Scott Tanser cross appeared to hit the hand of Dundee defender Ryan Sweeney. Referee John Beaton waved away the St Mirren players' fierce protests.
The Buddies were on top but still couldn't pierce the home side's defence.
Ronan picked out Tait on the right wing but, with Brophy taking up a dangerous position in the box, the full-back blazed over the bar with yet another chance going begging.
Robinson looked to youngster Henderson off the bench to inject some pace into his tiring front line.
Tait produced a crucial clearing header from a dangerous cross to help keep the scores level heading into the last ten minutes.
The Buddies went close to finding an all-important winner when Brophy's header sailed agonisingly wide of the post with Sharp beaten.
Jones almost squeezed in a dramatic late winner when his effort was squeezed wide, with the Saints finally finding the back of the net from a header only for Beaton to be quick to disallow it.
There was finally cause to celebrate for the Buddies in extra-time as Ronan rose to meet Henderson's glorious cross and almost burst the net, sparking wild celebrations in the stands behind the goal.