Chris Martin's late goal reignited Scotland's World Cup qualifying campaign and eased the mounting pressure on manager Gordon Strachan as he secured a 1-0 triumph over Slovenia at Hampden Park.
It looked destined to be another missed opportunity for the Scots as they spurned several chances before the break and then looked bereft of ideas in the second half.
But Martin struck two minutes from time to end Slovenia's resistance and move Scotland to within two points of Group F's second-placed side Slovakia, who beat Malta 3-1.
Scotland were well on top for the majority of the first half and carved out some great opportunities, with Robert Snodgrass often at the fore. Somehow they failed to go into half-time ahead, though, Leigh Griffiths guilty of a shocking miss as he struck the crossbar before then hitting the post.
Griffiths' day got even worse when he was withdrawn due to injury early in the second half, and with him went much of Scotland's impetus and presence in attack.
Substitute Ikechi Anya wasted one of Scotland's few second-half chances late on and the writing appeared to be on the wall, but Martin - only introduced from the bench in the 82nd minute - secured a potentially vital win at the death, injecting life into a qualification quest that looked to be running out of hope.
Scotland looked every inch a side desperate for all three points during the early exchanges, forcing Jan Oblak into action after just two minutes, with the goalkeeper pushing away Russell Martin's close-range effort following Snodgrass' corner.
Oblak had to be alert again shortly after, getting down to his right to parry Griffiths' deflected effort to safety.
After a brief lull, the hosts' next chance arrived just before the half-hour mark, with James Morrison sending a fierce half-volley agonisingly wide of the left-hand post.
West Ham winger Snodgrass was particularly threatening and he crafted an even better opportunity 10 minutes before the break, chipping a delivery to the unmarked Griffiths at the back post only for the striker to inexplicably smash on to the bar from a couple of yards out.
Griffiths was then denied by the right-hand post moments later, as he met James Forrest's square pass on the edge of the area with a first-time strike.
He made way for Steven Naismith with an apparent back problem just after the restart and Scotland also found Slovenia to be more compact at the back in the second period, resulting in chances becoming something of a rarity.
They did eventually create their first opening of the second half 15 minutes from the end, but Anya hit a tame effort right at Oblak just a few seconds after replacing Snodgrass.
Scotland's persistence paid off in the end, however, as Stuart Armstrong found Martin in the area with a clever reverse pass and the striker sent a left-footed finish across Oblak - who probably should have done better - and into the bottom-right corner, putting Strachan's side back into contention in Group F.
Get the best features, fun and footballing frolics straight to your inbox every week.
Thank you for signing up to Four Four Two. You will receive a verification email shortly.
There was a problem. Please refresh the page and try again.