Scotland's ailing World Cup qualifying hopes were given a late and much-needed boost when substitute Chris Martin scored a dramatic 88th minute winner which sealed a 1-0 win over Slovenia at Hampden Park.
Defender Russell Martin had the ball in the net early in the first half only to be punished for an infringement before striker Leigh Griffiths twice hit the woodwork.
Time seemed to be running out for Gordon Strachan's side but with two minutes remaining Martin - on for James Morrison - took a Stuart Armstrong pass and fired a low drive past goalkeeper Jan Oblak and in at the far post.
It took Scotland on to seven points from five fixtures at the the halfway stage of the campaign and into fourth place, two points behind second-placed Slovakia, ahead of the visit of Group F leaders England in June.
There had been a flat feeling to the occasion with the national stadium just over half full for matchday five.
Strachan made nine changes to the side which drew 1-1 with Canada in their friendly at Easter Road last Wednesday.
Celtic midfielder Armstrong as expected was handed his debut as one of six Hoops players in the side which saw Scott Brown regain the captaincy from Darren Fletcher, who was dropped to the bench.
More surprisingly was the decision by Strachan to move Parkhead left-back Kieran Tierney to right-back for the first time.
There was a minute's silence before the game in tribute to those who had suffered in the Westminster attack in midweek.
Hampden Park was quieter than usual but those Tartan Army members who did turn up got behind their team and were rewarded by a bright start.
Robert Snodgrass' corner from the right just after a minute was met by the boot of Martin eight yards out but Slovenia keeper Jan Oblak parried to safety.
Six minutes later Martin headed the next Snodgrass corner into the net but Dutch referee Bjorn Kuipers ruled he has pushed marker Miral Samardzic, to end Scottish celebrations.
The home fans jeered when Slovenia skipper Bostjan Cesar was booked in the 22nd minute for time wasting at a free-kick.
Six minutes later they almost cheered after midfielder James Morrison powered a drive in from the edge of the box but the ball missed the target by inches.
The opener which should have come in the 34th minute when Snodgrass got down the left to cross for Griffiths - but the Celtic striker volleyed against the crossbar from four yards out.
Moments later, Griffiths smacked the post with a low right-footed drive from Armstrong's cutback before a header from Morrison was cleared off the line by Slovenia attacker Valter Birsa.
Scotland keeper Craig Gordon had made a save from Roman Bezjak's angled drive but aside from that the visitors had threatened little in a first 45 minutes which were encouraging, but frustrating, for the Scots.
There was some despair when Griffiths, which had picked up a lower back injury when challenging Oblak in the first half, was replaced by Steven Naismith four minutes after the restart.
Hampden fell quiet again as the tempo dipped. The home side tried to increase the pressure but Slovenia, all work rate and little flair, would not allow Strachan's men to build any rhythm.
Belief appeared to slip as the contest entered its final stages, with Slovenia seemingly h appy to hold on for a point.
Ikechi Anya came on for Snodgrass in the 74th minute and, with his first touch, delivered a tame finish from 12 yards after being set up by James Forrest.
It was another good opportunity missed by the home side and it looked like an all too familiar hard luck story.
However, with two minutes remaining, Martin - who had replaced Morrison five minutes earlier - took a pass from Armstrong inside the box and drilled a low shot past Oblak and in off the far post to bring Hampden alive, at last.