Sam Davies converted a last-minute try as Wales shocked defending champions South Africa to reach the IRB Junior World Championship final.
The Baby Boks, who had ended New Zealand's dominance of the competition last year, had led 17-11 going into the final minutes.
However Davies produced a delightful chip for Ashley Evans to run on to and score in the corner. Davies then kept his cool to land the conversion to cap a thrilling comeback.
Davies had also landed two first-half penalties, while captain Ellis Jenkins crossed for a try after 56 minutes.
Irne Herbst and Kwagga Smith scored tries for the Boks, while Handre Pollard added two conversions and a penalty - although, crucially, he was off target with three other attempts at goal.
"Tonight the squad can relax and savour what they've done but we're keeping our feet on the ground for some hard work ahead," said head coach Danny Wilson.
"To beat South Africa is a great feeling but we'll be sticking to our usual recovery and analysis though this time we know we're preparing for a World Championship final.
"Parts of our game were excellent and although we have a few things to work on, we know what we have to do now in the final."