Jordie Barrett kicked a 79th-minute penalty to snatch victory for New Zealand over South Africa and secure the Rugby Championship title with a match to spare.
The 100th Test between rugby's two most successful nations did not disappoint, with All Blacks wing Will Jordan and his Springboks counterpart S'bu Nkosi both scoring early tries.
But from then on it was a kicking duel between South Africa out-half Handre Pollard and full-back Barrett to decide the spoils.
Ultimately, Barrett's 14 points from the tee were enough to regain the Rugby Championship title from South Africa and extend their winning streak to ten matches.
"We knew this game was going to come down to the wire," said New Zealand captain Ardie Savea.
"It was tit-for-tat out there. They put us under a lot of pressure."
After disappointing in back-to-back losses to Australia over the last two weeks, the Springboks were back to their clinical best at the North Queensland Stadium.
Scrum-half Faf de Klerk sent box kick after box kick into the Townsville sky and his forwards muscled up in the tight and at the set-piece.
The All Blacks scored first in the third minute when hooker Codie Taylor latched onto a loose ball and found room to burst up the middle before finding Jordan in support with a clear sprint to the line.
The Springboks hit back almost immediately with All Blacks wing George Bridge losing a De Klerk bomb in the evening sky and Nkosi pouncing to touch down.
Two Handre Pollard penalties gave South Africa an 11-7 lead after 13 minutes but Jordie Barrett put New Zealand back in front with two of his own, the second after Nkosi had been sent to the sin bin for a deliberate knock down.
New Zealand held the 13-11 half-time lead until Pollard's third penalty just before the hour mark but Barrett was quickly able to restore the slender advantage.
Another penalty after the collapse of a rolling maul allowed Pollard to put South Africa 17-16 in front in the 67th minute - a sixth change of lead - but Barrett was unerring when his chance came to seal the win.
"It was tough, it was an awesome contest and it was a fair contest," said Springboks captain Siya Kolisi.
"It's been a tough two weeks but I'm proud of the way the boys stood up today."