Fourie du Preez’s 75th-minute try ended battling Wales’ World Cup dream in a colossal World Cup quarter-final at Twickenham.
Wales led into the final 10 minutes, but finally succumbed after enduring a second-half battering.
Fly-half Handre Pollard kicked five penalties and a drop-goal for the Springboks.
Wales’ Dan Biggar scored 14 points and created the chance for Gareth Davies to score his fifth try of the tournament.
South Africa now face the winners of this evening’s Millennium Stadium match between New Zealand and France in Twickenham next weekend.