The team now needs another win to earn a place in Qatar after a thrilling semi-final play-off in Glasgow.
Ukraine dominated most of the match. Veteran captain Andriy Yarmolenko scored the first, deftly penetrating goal in the 33rd minute, and then helped Roman Yaremchuk with a header in the 49th to make the score 2-0.
A later Scottish resurgence of risky attacks gave the team a 79th-place goal from Callum McGregor before substitute Ukrainian Artem Dovbik took the lead to score the last shot of the game.
3,000 Ukrainian fans were among 51,000 at Hampden Park in Glasgow, Scotland.
They applauded each other with their arms raised high above their heads as Dovbyk led his teammates to the corner of the stadium to celebrate the victory.
Ukraine’s coach Oleksandr Petrakov said the victory went to “the armed forces in the trenches and hospitals, who give their last drop of blood to those who suffer every day in Ukraine.”
The country, which was invaded by Russia in February, will play Wales in the qualifying final on Sunday, with a World Cup spot on the line.
The Cardiff winner will travel to Qatar in November to play in a group against England, the US and Iran.
Ukraine is on a wave of global goodwill after the Russian invasion, and the strong desire of its players to reward the nation with a spot on the biggest football scene was evident.
All Ukrainian players entered the field, each with a blue and yellow national flag on their shoulders.
The warm welcome was accompanied by the performance of the national anthem of Ukraine “Ukraine has not died yet”, to which the Scottish fans applauded loudly. Many of the same fans stayed after the game to greet their victorious opponents outside the field.
“I also express my gratitude to the people of Scotland – an amazing, hospitable place,” said coach Petrakov.
Many Ukrainian fans have traveled far and planned to stay in the UK for the play-off decider against Wales on Sunday.
Georgiy Butromeev told The Associated Press before the game that he came from Toronto with friends to support the players who “need to show the people of Ukraine that we are warriors.”
“It’s not just about football,” said Yaroslav Grigorenko, who came from Amsterdam.
“It’s important to keep abreast of discussions here in Europe to keep (people) from forgetting what’s going on in Ukraine.”