The All Blacks were forced to grind hard before snatching a 19-17 victory over world champions South Africa in the 100th Test match between two of rugby's traditional powerhouses.
In front of a sellout crowd in Townsville, fullback Jordie Barrett's 40-metre penalty goal from out wide with two minutes remaining was the difference, as both teams fought tooth and nail for territory during Saturday''s contest.
The win ensured unbeaten New Zealand clinched the four-nation Rugby Championship title with a match in hand -- they face the Springboks again next weekend.
However, the All Blacks looked headed for an upset loss against a Boks team chastened after back-to-back losses to the Wallabies when five-eighth Handre Pollard kicked South Africa ahead 17-16 with just under 15 minutes remaining.
But a crucial turnover by replacement back Quinn Tupaea gave Barrett a chance to complete his perfect goal-kicking performance (5/5) and send the large contingent of All Blacks supporters into raptures.
The win sees the All Blacks overall record extend to 60 wins from 100 clashes with the Boks, with four draws in their history.
All Blacks coach Ian Foster said the scrappy and humid contest was what they expected but it was a learning experience for some his players who had never faced the world champions before.
"The performance wasn't really what we wanted but we were forced into a lot of errors from their pressure," he said.
"That was a game that we expected to come up against but hats off to them, I just loved our attitude when things weren't going well."
South Africa stuck to their tactical kicking guns throughout Saturday's contest sending 38 kicks the way of their opposition's back three.
Jacques Nienaber's side looked to slowly fight for territory through box-kicks via scrum-half Faf De Klerk, with fullback Barrett under sustained barrage throughout.
In the opening stanza it was New Zealand who flew out the blocks, opening the scoring when hooker Codie Taylor caught the ball off his boot laces and broke away from his own 40-metre line to set up winger Will Jordan for a try in the third minute converted by Barrett.
The Springboks immediately hit back when Sbu Nkosi picked up a dropped high ball from All Blacks winger George Bridge to score the game's only other try.
Down 7-5, the Boks kept to their high-ball pressure on New Zealand's back three, earning two penalties for Handre Pollard who kicked them to an 11-7 lead.
A territorial struggle then ensued for just under 20 minutes with neither team eager to play from within their own half.
But when Nkosi was yellow-carded for a deliberate knockdown in the 35th minute, Barrett slotted his third kick of the evening to take his side to a 13-11 halftime lead.
Pollard and Barrett exchanged second-half penalties before a collapsed rolling maul allowed Pollard to put South Africa ahead 17-16, only to be denied when Barrett provided the seventh lead change in the game with his late winning kick.
"I thought it was a proper Test match between the number one and the number two teams in the world," said Nienaber.
"It came down to the wire, a call here, a bounce of the ball there. Sometimes it goes for you and sometimes it goes against you."