The All Blacks held off a spirited fight from the hosts to pip South Africa 25-24 in a ferocious physical battle in Cape Town and end their Rugby Championship campaign unbeaten.
Each side scored three tries in a thrilling spectacle as South Africa restored some pride with a competitive and combative display after being beaten by a record 57-0 scoreline in New Zealand last month.
The All Blacks tries came from Ryan Crotty, Rieko Ioane and Damian McKenzie while Ross Cronje, Jean-Luc du Preez and Malcolm Marx scored for the home side.
New Zealand led 8-3 at half-time after a bruising first half that lasted nearly 50 minutes but were given a scare as Marx's 79th-minute try, converted by Elton Jantjies, took the hosts to within a single point.
But they held on to finish the southern hemisphere championship with a 100 percent success rate for a second successive year.
They had already secured the title for a fifth time in six years last week.
The teams traded early penalties before Crotty scored a first try for the All Blacks, chasing on to a charge down by Beauden Barrett and scrambling beyond the try line to ground it. The points were awarded after lengthy deliberations by the Television Match Official.
The first half extended for eight minutes after the hooter as the two teams kept the ball alive, looking for a score in a bruising battle of attrition.
After the break, South Africa piled on the pressure in the scrum and scored within five minutes as scrumhalf Ross Cronje took the ball from the ruck to go over.
The conversion from Elton Jantjies put South Africa 10-8 up but New Zealand could have been quickly back ahead had Lima Sopoaga not missed a kickable penalty from 45 metres.
With the crowd behind them, the Springboks surged forward to try to extend their lead, only for wing Ioane to pick off an interception and outsprint the defence, running 80 metres for a second New Zeland try.
But within three minutes South Africa had restored their two-point advantage as hooker Malcom Marx Marx took the ball inside the 22 and set up substitute loose forward Jean-Luc Du Preez for the try.
A moment of magic again proved the catalyst for the All Blacks at a decisive moment in the game as a counter-attack by David Havli, on for only his second cap, caught out a disjointed defensive line and saw McKenzie jink his way over.
South Africa then lost centre Damian de Allende to a red card in the last five minutes for a late tackle on Sopoaga as he went wide with a drop kick effort.
Even down to 14 men, South Africa rallied in the closing stages, and Marx scored with less than two minutes remaining.
But a turnover as they pressed forward in search of an upset win allowed the All Blacks to kick out the ball and claim the victory - and 100 percent record.
The All Blacks now look forward to the third and final Bledisloe Cup clash with Australia in Brisbane later this month.