Replacement Francois Hougaard was the South African hero with a try in the 65th minute which was enough to beat Wales 17-16 in their Rugby World Cup Pool D match in Wellington.
He capped a sustained South African period of pressure to score under the posts and wrest the lead from the heroic Welsh.
South Africa had taken a 10-6 lead into the break after an action-packed first spell.
Wales, playing at breakneck speed which harried the Springboks, reduced the lead to a single point when James Hook kicked a penalty goal from in front just after the break.
And Wales took a 16-10 lead after more sustained pressure when No.8 Toby Faletau dived over for a try in the 54th minute, which was converted by Hook.
Wales missed two shots at goal which could have extended their lead.