A combination of good fortune and heroic defending helped Rob Page's team get over the line, securing their place in a group alongside England, Iran and the United States when the Finals get underway in November.
After two passionately-sung national anthems, both teams set about trying to gain an early advantage, and Ukraine's Oleksandr Zinchenko saw a long-range free kick cancelled out by the referee, who deemed that it had been taken too quickly.
Wales were having their own moments in attack, but it was the visitors who were creating the better opportunities, Wayne Hennessey being called upon several times during the opening 45 minutes.
As well as a number of interventions from shots from distance, the veteran stopper also had to get down to his right to deny Roman Yaremchuk after he had broken clear of the defence.
Nevertheless, with 11 minutes of the first half remaining, Wales went in front. The set piece from 30 yards was far from ideal for a left-footer - even Bale's - but the legendary forward's effort was deflected into the net by the head of Yarmolenko.
Moments after the restart, the Dragons should have doubled their lead, the initial brilliant work being done by Neco Williams and Bale before Aaron Ramsey sent a first-time effort from 10 yards wide of the far post.
In a contest which saw both nations trade blows at either end of the pitch, chances were squandered on a regular basis, Ukraine unable to force their way past an inspired Hennessey.
Up the other end, substitute Brennan Johnson struck the post soon after his introduction, before Bale saw a tame effort at the back post directed too close to the goalkeeper.
From a Wales perspective, the clock was running down slower and slower but all of their backline - most notably Ben Davies - delivered one of the strongest rearguard performances of their careers.
Wales avoided further alarms during five minutes of added-on time, the final whistle sparking jubilant scenes both on and off the pitch as the nation qualified for their first World Cup since 1958. body check tags ::