The match at the Westpac Stadium started to script with the hosts, who had won 11 of their previous 12 games against South Africa, racing into a 12-0 lead thanks to tries from Jordie Barrett and Aaron Smith.
But South Africa, who went into the game on the back of defeats to Australia and Argentina, racked up 21 unanswered points with Aphiwe Dyantyi, Willie le Roux and Malcolm Marx crossing for tries.
Rieko Ioane cut the deficit to four points but Handré Pollard converted a penalty on the stroke of half time to extend South Africa’s lead to 24-17
That advantage became 14 points early in the second half when Cheslin Kolbe intercepted the ball and scored.
Ioane’s second touchdown in the 52nd minute brought it back to 31-24. However Dyantyi’s second try of the match restored the 12 point lead.
Though the hosts surged again with tries from Codie Taylor and Ardie Savea, Beauden Barrett’s failure to convert the extra two points for the tries, allowed the visitors to notch up their first win over the All Blacks since 2014.
“I am very happy for the effort,” said South Africa captain Siya Kolisi. “It has been a tough couple of weeks following the defeats to Australia and Argentina but I have no words for the way we’ve carried ourselves and the way we’ve worked and believed in ourselves.”
The victory will relieve the pressure on South Africa head coach Rassie Erasmus who suggested before the match that his job was on the line if the side were to lose.
All Blacks skipper, Kieran Read, was generous in defeat. “My boys kept working hard but the South Africans defended well and deserved the win," he said.
“They put us under pressure and we didn’t quite respond the way we needed to.”