The Springboks wiped out an alarming 16-3 deficit to score 28 points in the second and third quarters – but Wales came desperately close to claiming only a second win in 104 years against the Springboks.
Wales matched South Africa 3-3 on tries – centre James Hook, 18-year-old wing Tom Prydie and substitute lock Alun-Wyn Jones touching down – while the Springboks replied with scores for wing Odwa Ndungane, flanker Dewald Potgieter and centre Juan de Jongh.
Fly-half Ruan Pienaar kicked 16 points and full-back Francois Steyn slotted a long-range penalty, with Stephen Jones booting 13 points and Hook dropping a goal for Wales.
Wales now head off on a demanding two-Test tour of New Zealand, knowing that they missed a chance to defeat what was a second-string Springboks side.
Jones' ninth-minute penalty opener gave Wales a deserved lead, before Hook doubled the advantage through a drop-goal.
Jones and his opposite Pienaar exchanged penalties as Wales preserved a six-point advantage before the home side pounced in opportunist fashion.
Hook capitalised on a gift from his opponents. Springboks skipper John Smit threw out an ambitious midfield pass but it went straight to Hook and he sprinted for a try which Jones converted. Wales, playing with fluency and rhythm, found themselves 16-3 in front before a second Pienaar penalty reduced South Africa's deficit.
Wales' defence came under siege before the Springboks fired possession wide and Ndungane scored.
Pienaar sent the touchline conversion attempt wide but ended the scoring in a fast and furious first-half by completing his penalty hat-trick.
And the Springboks needed less than three minutes of the second period to go ahead for the first time.
Danie Rossouw's delicious one-handed pass to Potgieter sent him through an inviting gap, with Pienaar adding the extras.
Wales then battered away deep inside South Africa's 22, but the streetwise visitors were able to snaffle possession and hack it upfield, gain a penalty and Steyn did the rest from almost 50 metres.
Things quickly deteriorated from a Welsh perspective when South Africa ended the third quarter by moving past 30 points through an exquisite converted De Jongh try.
The seven-point blast left Wales with it all to do, and however hard the home side huffed and puffed – Davies was held up over the South African line 11 minutes from time – they hinted at no way back until teenager Prydie touched down.
Another Pienaar penalty looked to have made South Africa safe, but Jones grabbed a try which set up a nerve-jangling final four minutes.
Fly-half Quade Cooper orchestrated four tries with his clever passing and scored one himself to lead Australia to a 49-3 victory over Fiji in their Test match at Canberra Stadium yesterday. Winger Digby Ioane and full-back Kurtley Beale scored two tries each and Cooper, No.8 Richard Brown and replacement Drew Mitchell also crossed for the home side.