Andriy Yarmolenko, Roman Yaremchuk and Artem Dovbyk scored the goals for Ukraine to set up a play-off final away to Wales on Sunday for a place in Qatar later this year.
The match had been moved from March, just weeks after the war began, to give Ukraine the chance to fulfil the fixture.
Six of the starting line-up for the visitors are still contracted to Ukrainian clubs and had not played competitively for months.
Manchester City’s Oleksandr Zinchenko broke down in tears on the eve of the game as he described how much it would mean to take Ukraine to the World Cup.
But they showed no signs of rust or letting the expectation of a nation weigh heavily on their shoulders.
The Ukrainian players entered the field draped in yellow and blue flags before an emotionally-charged national anthem which was applauded from all sides of the stadium.
Among the Ukranian support, children held up signs saying “stop war.”
However, once the action got underway, it was the small band of travelling supporters who had travelled from around the world to see their country who had far more to cheer.
Scotland goalkeeper Craig Gordon kept his side in the game early on.
The Hearts goalkeeper was named player of the year this season in the Scottish Premiership and showed why with stunning saves to deny Viktor Tsygankov and Yarmolenko.
Ukraine’s greater poise and technical ability soon told, though, as from Ruslan Malinovskyi’s through ball, Yarmolenko’s perfect control allowed him to lob the onrushing Gordon to make it 1-0 just after the half-hour mark.
Scotland had been unbeaten in eight games, but rarely threatened a response to keep alive their hopes of reaching a first World Cup since 1998.
Manager Steve Clarke tried to turn the tide at half-time by introducing Ryan Christie for the ineffective Lyndon Dykes in attack.
Within four minutes of the restart, Scotland’s mountain to climb got even steeper when Benfica striker Yaremchuk headed in Oleksandr Karavayev’s cross to the back post.
Scotland finally flickered into life to appease a frustrated sell-out crowd of 50,000 at Hampden Park in the final quarter.
John McGinn somehow headed wide from point-blank range after Georgiy Bushchan spilled Scott McTominay’s cross.
Another Bushchan error then did give Scotland a lifeline 11 minutes from time when Callum McGregor’s strike slipped through his grasp and just crossed the line before the defender could clear.
The Scots, though, lacked imagination in their search for an equaliser as Ukraine repelled a flurry of long balls.
Dovbyk then broke clear in the final seconds to put the seal on an emotional win by smashing home at Gordon’s near post.