A brace from new cap Hadleigh Parkes helped Wales beat South Africa 24-22 in their end-of-year Test at the Principality Stadium in Cardiff.
Wales dominated the first half and led 21-10 at the break. A spirited fightback from the Springboks in the second put them ahead, but a late penalty gave Warren Gatland's team the win.
A Dan Biggar masterclass in the opening stages left the Springboks reeling.
First, his cross-kick found Hallam Amos, who set Scott Williams up for the opening try in the fifth minute, which Leigh Halfpenny converted.
Then, three minutes later, Biggar chipped the ball through for Parkes to gather and score. Once again, Halfpenny added the extras.
Malcolm Marx thought he had powered his way over at the other end in the 19th minute, but TMO Rowan Kitt was less convinced and awarded the Springboks nothing more than a five-metre scrum.
With 10 minutes left of the first 40, Josh Navidi was penalised for a high tackle on Handré Pollard. The fly-half then stepped up to the tee and put South Africa on the board.
However, it seemed that every silver lining preceded another cloud for the visitors. In the 33rd minute, Wales scored their third try. Andries Coetzee's charged-down kick was chased by Taulupe Faletau, who passed inside to Parkes for yet another finish.
On the stroke of half-time, Warrick Gelant pulled a try back on his first start. Dillyn Leyds initiated a counter-attack for the Springboks and Jesse Kriel put a clever kick through for the Blue Bulls youngster to chase and dot down. Pollard nailed a well-executed conversion kick.
The Springboks picked up where they left off at the start of the second half, and after a sustained spell of pressure, Pollard went over for their second try six minutes in. However, he failed to convert this time.
In the 55th minute, South Africa struck again. They worked the ball out left, with Malcolm Marx getting the final pass away to Jesse Kriel, who crashed through Halfpenny's poor tackle and scored. Pollard put the Springboks in front with a fantastic conversion.
Wales went back in front in the 68th minute with a Halfpenny penalty after Pieter-Steph du Toit was blown up for not rolling away.
Unfortunately for Allister Coetzee's side, they were unable to fight back again and the hosts held on for a much-needed victory, ending a difficult year on a high note.
Tries: Williams, Parkes 2
Cons: Halfpenny 3
For South Africa:
Tries: Gelant, Pollard, Kriel
Cons: Pollard 2
Wales: 15 Leigh Halfpenny, 14 Hallam Amos, 13 Scott Williams, 12 Hadleigh Parkes, 11 Steff Evans, 10 Dan Biggar, 9 Aled Davies, 8 Taulupe Faletau, 7 Josh Navidi, 6 Aaron Shingler, 5 Alun Wyn Jones (c), 4 Cory Hill, 3 Scott Andrews, 2 Kristian Dacey, 1 Rob Evans
Replacements: 16 Elliot Dee, 17 Wyn Jones, 18 Rhodri Jones, 19 Seb Davies, 20 Dan Lydiate, 21 Rhys Webb, 22 Rhys Patchell, 23 Owen Watkin
South Africa: 15 Andries Coetzee, 14 Dillyn Leyds, 13 Jesse Kriel, 12 Francois Venter, 11 Warrick Gelant, 10 Handré Pollard, 9 Ross Cronje, 8 Dan du Preez, 7 Pieter-Steph du Toit, 6 Siya Kolisi, 5 Lood de Jager, 4 Eben Etzebeth (c), 3 Wilco Louw, 2 Malcolm Marx, 1 Steven Kitshoff
Replacements: 16 Bongi Mbonambi, 17 Trevor Nyakane, 18 Ruan Dreyer, 19 Oupa Mohoje, 20 Uzair Cassiem, 21 Louis Schreuder, 22 Elton Jantjies, 23 Lukhanyo Am
Referee: Jérôme Garcès (France)
Assistant referees: Wayne Barnes (England), Frank Murphy (Ireland)
TMO: Rowan Kitt (England)