Warren Gatland's looked set to cause an upset as they led the Springboks 16-10 with 15 minutes remaining - with Wales dominating possession and territory.
Jamie Roberts, Rhys Priestland and skipper Sam Warburton were simply immense - with the defending world champions lacking ideas and direction.
But in an absorbing contest, South Africa - just like England 24 hours earlier - found a way to win when it mattered the most.
Frans Steyn and replacement back Francois Hougaard scored tries, while Morne added seven points from the boot.
For Wales Toby Faletau, whose dad played for Tonga at the 1999 World Cup, scored their only try while James Hook landed 12 points.
Wales had got off to the worst possible start as Frans Steyn crashed over in corner after a sustained spell of pressure in the fourth minute.
The Boks pack had hammered away at the Welsh defence before quick hands found the full-back out wide and he used his strength to power over Hook. Morne Steyn converted.
Wales responded well with three points from Hook coming after some nice phases of play - with Priestland getting the back division moving.
However, a second penalty went agonisingly close - and the miss was compounded as Morne Steyn was on target with a three-pointer of his own.
Wales did enjoy large spells in the South Africa half but despite playing with real purpose they just couldn't find a way through the defence of the world champions.
Hook, though, did cut the gap to four points with another penalty.
That gap was down to a solitary point 10 minutes in to the second half after another Hook penalty, with the Boks struggling to get out of second gear.
Sensing an upset, Wales upped the pressure - with the Boks lacking direction and ideas.
And Wales finally got the try they deserved when Faletau stormed through a gap to dive over. Hook converted.
However the South Africa response was immediate and after they had drove into the heart of the Wales defence, Francois Hougaard sliced through some poor defending - with Morne Steyn conversion putting the Boks back in front with 15 minutes left.
Priestland attempted to put Wales back in front with a drop goal, but his effort was way off target - as was Hook's penalty effort with seven minutes left.
And it was South Africa who closed out the match in the Wales half, with their experienced pack eating up the time at the breakdown.
Gilbert has released a new line of rugby cleats. The Gilbert Virtuo 8S is part of the exciting new product. Check it out.
The Barbarians are one of the top invitational rugby sides with a long history and classic rugby jersey.
The Nike Tiempo is a solid rugby cleat and one of few styles still made from full-grain natural leather.
The Lions get ready for their matches with this green training jersey. It's what the players wear. Get in the Gear!
A cool looking all black rugby cleat with the high performance adidas is known for. Get in the Gear!
Wear the crest of the British and Irish Lions on your t-shirt. A great look for the summer.
$29.99
The Lions are ready to get their Australia tour underway. They arrive in Perth on Monday.
The New Zealand All Blacks training jersey for 2013/14. Get in the Gear!
The USA Rugby Pro Alternate rugby jersey is perfect for any fan of the Eagles. Get yours to wear during the summer Test matches.
The NEW All Blacks 2013/14 jersey has arrived at World Rugby Shop. Dare to wear the colors of the All Blacks.