Wales bravely failed in a bid to win a first series against the Springboks in South Africa as the hosts triumphed in the third Test decider in Cape Town.
South Africa fly-half Handre Pollard scored 20 points with hooker Bongi Mbonambi and captain Siya Kolisi crossing for tries.
Wales responded with a try for flanker Tommy Reffell and three Dan Biggar penalties.
Taulupe Faletau and Gareth Anscombe were late Wales injury withdrawals.
It proved a game too far for Wayne Pivac's side against the world champions as Wales could not follow in the footsteps of Ireland and England, who had clinched series success against New Zealand and Australia earlier in the day.
The tourists, though, can return home with pride and purpose considering the low expectations before they had arrived in South Africa three weeks ago.
After losing at home to Italy in March in the final game of this year's Six Nations, Wales were written off against the world champions.
Most were anticipating a 3-0 home series triumph, but Wales made a mockery of pre-tour predictions going into the final game.
The series was level after the hosts had won the opening Test 32-29 in Pretoria and the visitors had battled back with a 13-12 win in Bloemfontein, a first Wales men's win over the Springboks on South Africa soil.
Wales' hopes were hampered after suffering a double blow before kick-off in Cape Town with number eight Faletau and replacement fly-half Anscombe ruled out through injury.
Faletau was shaking his head as he left the field with an injury to his side after the warm-up, consoled by Pivac, and his absence prompted a back-row reshuffle with Josh Navidi stepping up to number eight and Taine Basham coming on to the bench.
Anscombe, who kicked the winning conversion in the second Test win, was missing with a rib injury.
South Africa head coach Jacques Nienaber had reverted to his tried and trusted side after making 14 changes for the second Test defeat.
Nienaber made 10 more personnel alterations for the finale with the side resembling the team that took the field in Pretoria with 11 starters from the 2019 World Cup final triumph.
Only lock Eben Etzebeth started all three Tests and he led his side out on his 100th international in which he was named man-of-the-match.
South Africa started brightly with wing Makazole Mapimpi denied a try after his foot was in touch when collecting a Lukhanyo Am kick.
The Springboks had to be content with an Handre Pollard penalty. South Africa were dominating the aerial battle in the early exchanges and full-back Damian Willemse collected his own kick before being hauled down illegally by Biggar.
It laid the platform for Damian de Allende to try and power over, but the centre was deemed just short.
The onslaught continued as the Springboks' scrum dominance sprung into action as Wales continually infringed and the pressure told as Pollard dived over and converted.
Dan Lydiate was forced off with a blood injury after clashing heads trying to tackle Pollard.
Lock Alun Wyn Jones was sent on instead of flanker Basham with Will Rowlands switching to the blind-side flank.
After no early possession or territory, the visitors started to play some attacking rugby with centre George North, on the day he became Wales' most capped back in his 105th appearance, prominent in the flowing build-up.
After North and Louis Rees-Zammit's bursts, Josh Adams set up the supporting flanker Reffell to score.
South Africa wing Cheslin Kolbe was forced off and replaced by full-back Willie le Roux with Willemse switching to centre and Am going on to the right flank.
Wales' set-piece issues and discipline gave South Africa the ascendency with referee Matthew Carley issuing a final warning to Biggar.
The tourists settled and Biggar reduced the deficit with a penalty.
South Africa battled back with a try from hooker Mbonambi on his 50th appearance from a driving maul. Pollard converted to give South Africa a 17-8 half-time lead.
Wales brought on front-row reinforcements during the interval with Sam Wainwright and Dewi Lake replacing Dillon Lewis and Elias before Biggar scored the opening points of the second half with a penalty.
South Africa were denied a third try when scrum-half Jaden Hendrikse's pass to Am was deemed forward.
After the Springboks changed their front row, Biggar brought Wales within three points with his third penalty.
After some poor Wales play in their own 22, Springboks retaliated with a try by captain Kolisi that Pollard converted.
Basham offered Wales dynamic ball carrying after replacing Reffell as Wales went in search of clawing back the 10-point deficit but an attacking lineout throw in South Africa's 22 crucially went astray.
Their efforts proved to be in vain as Pollard settled the victory with two late penalties.
Line-ups
South Africa: Willemse; Kolbe, Am, de Allende, Mapimpi, Pollard, Hendrikse; Nyakane, Mbonambi, Malherbe, Etzebeth, de Jager, Kolisi (capt), du Toit, Wiese.
Replacements: Marx, Kitshoff, Koch, Mostert, Smith, Louw, de Klerk, le Roux.
Wales: L Williams; Rees-Zammit, North,Tompkins, Adams; Biggar (capt), Hardy, Thomas, Elias, Lewis, Rowlands, Beard, Lydiate, Reffell, Navidi.
Replacements: Lake, Wyn Jones, Wainwright, Alun Wyn Jones, Basham, T Williams, Patchell, Watkin.
Match officials
Referee: Matthew Carley (England).
Assistant referees: Angus Gardner (Australia), Nika Amashukeli (Georgia).
TMO: Brett Cronan (Australia).