John McGinn the Hampden hero as he came off the bench to snatch a win against 10-player Croatia in the Nations League to end Scotland's 10-game run without a competitive victory.
Hopes of finishing second are all but over, but Steve Clarke's side can secure third and avoid automatic relegation if they win their final game in Poland.
The Croatians started with intent as Craig Gordon produced a string of saves before the game turned when Petar Sucic was sent off before the break after picking up a second booking for a barge on John Souttar before the break.
Scotland wasted a string of chances but McGinn, back in the squad after injury, crashed the ball into the net to wild celebrations after some magic from Ben Doak down the right wing.
The win keeps their hopes alive in A1. A win against Poland on Monday would guarantee third spot and a play-off against a League B side, though if they win and Croatia lose against Portugal with a three-goal swing they could yet find themselves in the quarter-finals.
Scotland end long wait for victory
Scotland head coach Steve Clarke claimed his team selection had been giving him "sleepless nights" and one of his dilemmas became clear when McGinn was named among the substitutes.
The Aston Villa captain missed last month's double-header through injury but he became super sub as he drew level with Ally McCoist on 19 goals in fifth place in Scotland's all-time list.
Another big decision was handing Tommy Conway his first start in his third international, the only change to the team that started the goalless draw with Portugal.
Clarke's choice of striker was immaterial in the opening stages as his side struggled to get out of their own half.
The visitors started strongly and Kenny McLean gifted them an early chance when he passed straight to Andrej Kramaric who fortunately shot wide.
Craig Gordon then produced a brilliant save to deny the Croatia striker, reacting quickly to get his boot to the ball to send it past the post.
After some desperate defending Scotland did manage to get forward. Ben Doak squared the ball to Scott McTominay on the edge of the box, Dominik Kotarski stopped his powerful effort.
The Tartan Army were lifted by that and three quick corners before Croatia regained control with Luka Sucic's cross-shot deflected wide.
Gordon then showed again why he is still Scotland's best number one as gathered Josko Gvardiol's effort seconds after punching Luka Sucic's strike clear.
The visitors had impressed but were down to 10 before the break. Petar Sucic picked up a second booking for a barge on Souttar. It was soft, but it was a glimmer of hope for Steve Clarke's side.
The Scots returned after the break with confidence and ambition. McTominay's header looped just wide with Andy Robertson's cross then hacked clear by the Croatia defence.
The chances kept coming but they couldn't take them. Gilmour fired well over with Doak begging for the ball, then the winger sent Ryan Gauld's cross past the post.
Croatia continued to carry a threat with Ivan Perisic firing just wide before Gilmour again sent another chance soaring over the bar.
The game was wide open and Mario Pasalic passed up a brilliant chance for Croatia. He got the wrong side of Anthony Ralston but prodded his one-on-one chance with Gordon wide.
Then as time was running out, McGinn took his chance as he smashed the ball in after collecting from Doak who had impressed from kick-off.
What's next for Scotland?
Scotland's final Nations League match is away to Poland on Monday night. Kick-off 7.45pm.