A late penalty try denied Wales an historic first victory over the Springboks in South Africa.
Liam Williams was penalised for a dangerous tackle on Cornal Hendricks as the South African wing looked set to score in the corner in the 78th minute.
And that handed Morne Steyn a straightforward conversion from in front of the posts to hand the hosts a 31-30 victory.
Wales mustered two late opportunities for Dan Biggar but the Wales fly-half fell short with both drop-goal attempts from the halfway line.
It was a bitter disappointment for Wales, who had led 17-0 in the first half and 30-17 with 10 minutes remaining.
Jamie Roberts, Alex Cuthbert and Ken Owens all crossed for Wales in a vastly improved display from last week's capitulation in Durban.
However, indiscipline again proved costly as Wales conceded two penalties tries, either side of a score by Hendricks, and were reduced to 13 men during the first half after two players were binned.
Having blown away the cobwebs in Durban last week, Wales began far more impressively at Nelspruit and stunned the Mbombela Stadium by galloping into a shock 17-point lead.
Jannie du Plessis was penalised from Jamie Roberts' thrust and Biggar kicked the opening points on 13 minutes while Du Preez missed his first effort.
Roberts was then involved again moments later for the game's first try.
The Welsh scrum, anchored by 21-year-old Samson Lee who started ahead of Adam Jones, held firm to hand Biggar the perfect attacking platform.
Biggar sent Alex Cuthbert crashing through, the wing bouncing off two tackles before he found Roberts on his shoulder. The centre rode the challenge of Jan Serfotnein to score under the posts. Biggar converted for a 10-0 lead on 19 minutes.
South Africa had been caught on the back foot and when Steyn failed to collect a lose ball, Jonathan Davies recovered leading to Wales' second try.
Liam Williams almost stepped through and Davies was strong before Cuthbert crashed on to Biggar's pass through Serfontein on the line. Biggar converted for a remarkable 17-0 scoreline after 30 minutes.
However just as in the first Test, Welsh indiscipline was to prove costly as the Springboks capitalised on yellow cards with 14 unanswered points.
South Africa's driving lineout was the source of Wales' problems and Luke Charteris was binned for infringing as the green jerseys surged forward.
The Springboks looked to have blown the chance when Dan Lydiate stole a lineout but back they came for a fourth attempt.
With Francois Louw carrying at the tail of a devastating drive, Biggar was penalised and referee Steve Walsh awarded South Africa a penalty try, converted by Steyn, and sent the Welsh fly-half to join Charteris in the sin bin.
South Africa immediately stepped on the gas against 13 men and from the kick-off, spread play wide to find space. Again it was full-back Willie le Roux who proved most effective, following JP Pieterson's break before sending Hendricks clear for a try.
Wales clung on to their 17-14 lead to half-time and, once back to full strength, rocked South Africa again by extending their lead.
Dan Lydiate and Alun Wyn Jones surged from a lineout and Davies went close before hooker Owens dived between Tendai Mtawarira and Duane Vermulen, stretching out to score. Biggar converted to hand Wales a 24-14 advantage on 46 minutes.
Wales dug in to withstand the expected response while Steyne and Biggar traded penalties to maintain the 10-point gap.
South Africa were then reduced to 14 men when lock Flip van der Merwe was binned for tackling Alun Wyn Jones in mid-air.
Wales' pack, scrummaging against seven Springbok forwards, earned another penalty and Biggar converted his sixth kick to put Wales 30-17 ahead and dreaming of an historic win.
Pieterson launched a counter-attack that was initially repelled by brave Welsh defending but was finally undone by the footwork of Le Roux.
South Africa mounted a final attack and worked space out wide for Hendricks, who beat North before he was clattered by an illegal tackle from full-back Williams on the line.
Tries: Penalty try 2, Hendricks, Le Roux
Cons: Steyn 4
Tries: Roberts, Cuthbert, Owens
Cons: Biggar 3
Pens: Biggar 3