Replacement five-eighth Gareth Anscombe kicked a sideline conversion with less than two minutes left to give Wales a 13-12 victory and its first over the Springboks on South African soil.
Anscombe’s nerveless kick, following wing Josh Adams’ late try, shocked the world champions in Bloemfontein, but also made them pay for a selection gamble when they changed 14 of their 15 starters from the first Test and gave six players debuts with a series still in the balance.
It also shook up the world rankings, which France now top for the first time in history, despite barely scratching past Japan, 20-15, on Saturday.
Watch the Wallabies vs England series decider live on 9Now plus All Blacks vs Ireland, Springboks vs Wales and Pumas vs Scotland ad free and exclusive on Stan Sport
Ireland, having made history of their own by beating the All Blacks in New Zealand for the first time, are up to second, while world champions South Africa slip to third.
The battered All Blacks dropped two places to fourth while England’s second Test win over Australia will see them leapfrog the Wallabies into fifth spot.
Wales pounced on the opportunity to level the series 1-1, with a decider next Sunday (AEST) in Cape Town.
READ MORE: Djokovic triumphs as Kyrgios explodes at box, umpire
READ MORE: Kyrgios explains what happened with drunk fan in final
READ MORE: Bellamy ‘seething’ as ‘serious cracks’ appear at Storm
“It’ll be an interesting (South Africa) team (next week) but it’ll be the strongest team,” Wales coach Wayne Pivac said.
“Two tight contests coming down to the last play, so we think we’ll put up a contest like these two weeks.”
Wales showed outstanding resilience after losing Alun Wyn Jones to a harsh yellow card and captain Dan Biggar to a shoulder injury, and then going 12-3 down with 20 minutes to play at Free State Stadium.
Stand-in captain Handre Pollard kicked all of South Africa’s points, but the Boks ran out of steam and didn’t score in the last 20.
Anscombe, replacing Biggar, closed it to 12-6 before putting a pinpoint late penalty into touch near the Springboks’ tryline to set up the game-winning play.
With an advantage for South Africa collapsing a lineout maul, the Welsh forwards worked their way to centre field before Anscombe released Adams on a big overlap on the left, and he beat the cover defence for his 77th minute try, the only one of the game.
Adams was also on as a replacement early when Alex Cuthbert went off hurt.
Anscombe faced a tough conversion but it sailed through the posts to make history for the Welsh, who have been trying to win a Test in South Africa for 58 years.
“There’s been some good Welsh teams to come here. Everyone deserves a pat on the back,” Biggar said.
“I know the Six Nations was disappointing, but we were unlucky not to win last week. We’ll enjoy tonight and to win the series would be even better.”
They have a chance at a series win and South Africa faces a backs-against-the-wall final Test, where another loss would put a severe dent in coach Jacques Nienaber’s plans a year out from a Rugby World Cup defence.
“We said from the start that we had a plan for 42 players,” Nienaber said.
“If we had gone the conservative route and stuck with the same team – and let’s say we didn’t win the Test match tonight – then we would probably have never given the other guys an opportunity.
“There was risk, but the answers you get out of it outweigh the risk.”
Before the series, most South African analysts were arguing over how many points the Springboks would win by in each Test.
But Wales pushed the first-choice Springboks to the brink in the opening game at Loftus Versfeld and was unlucky to lose that.
South Africa escaped with a 32-29 win with a penalty after the final hooter.
“The boys were so keen to get the job done after last week,” Pivac said.
“We’re disappointed we are not 2-0 up. It’s a big week for us now.”
Wales kept faith with most of its team for Bloemfontein, bringing in Cuthbert for Adams in its only change.
Nienaber changed everyone except lock Eben Etzebeth, a decision viewed as disrespectful to Wales by some.
A Wales victory still seemed unlikely when, with the game at 3-3 at halftime, South Africa ground itself into a nine point advantage through Pollard’s boot midway through the second half.
But Wales was composed and stayed disciplined to gain the lead, and a late South African surge after the fulltime hooter came to nothing as prop Vincent Koch knocked on, and the Welsh celebrated for the first time in South Africa.
For a daily dose of the best of the breaking news and exclusive content from Wide World of Sports, subscribe to our newsletter by clicking here!