In a game that tested the lawbook in rare fashion, a first half that lasted 58 minutes and saw the Australians come back from 13-31 down to push the All Blacks to the limit, it had everything.
Three yellow cards to Australia, two of them at the same time, and one for New Zealand made it a niggly game, yet the last-minute try kept the All Blacks in the hunt to claim the Rugby Championship in the return match at Eden Park on Saturday week.
Australia tested the limits of the law and paid the consequences with three yellow cards, but all that may pale with referee Matthieu Raynal's last-minute decision to penalise them for time wasting in front of their goalposts.
Raynal explained that when the penalty from the breakdown was awarded time was stopped. When it resumed he told Australia first five-eighths Bernard Foley to play, but he delayed, and delayed, and Raynal awarded the All Blacks the scrum that provided Barrett's try.
New Zealand put the pressure on from the start but Australia, while rattled early, settled down and refused to bow.
Australia failed to take the kick-off to start the game and the All Blacks pounced with immediate effect. Australia conceded three penalties and each time the All Blacks put their lineout to use, finally succeeding with hooker Samisoni Taukei'aho crossing in the third minute.
Enjoying some time with the ball, much of it generated by halfback Jake Gordon, including a high kick that bounced favourably for No8 Rob Valentini who kicked it down the sideline to set up the chance for a penalty goal, and then a try to fullback Andrew Kelleway.
However, the 20th minute try was disallowed when television evidence showed All Blacks centre Rieko Ioane prevented the ball from being grounded.
Raynal twice penalised the All Blacks for closing the gap at the lineout. On the second occasion in the 24th minute, they secured a try for Valetini when the maul split. In the process, replacement flanker Dalton Papali'i, who had just come on for Sam Cane, who was having an HIA which he failed, was sin-binned for bringing the maul down.
Valetini, and flankers Pete Samu and Rob Leota, had the desired effect for Australia. Samu made a superb break that provided the momentum that lead to Valetini's try, while Leota was strong in the breakdown and on the tackle.
The game came unstuck in the latter stages of the half which was extended to 58 minutes. Australia lost wing Tom Wright to the sinbin for cynical play after a sensational midfield run by wing Caleb Clarke.
Then the TMO saw dangerous play when replacement forward Darcy Swain hit replacement second five-eighths Quinn Tupaea with an illegal tackle to his leg when he was emerging from a ruck. Swain appeared fortunate to have only a yellow card.
Tupaea had to be assisted from the field with a knee injury, leaving both he and Havili, who failed an HIA, out of the game. That saw Beauden Barrett on to play fullback with brother Jordie moving to second five-eighths.
New Zealand went close to scoring again just before the break from a lineout drive only for Gordon to knock the ball from Taukei'aho's hand as he attempted to ground the ball.
It took only 52 seconds to take advantage of Australia being reduced to 13 men when from the restart the Beauden Barrett kicked to Will Jordan's wing and the ball was moved with Rieko Ioane and No8 Hoskins Sotutu running before Sotutu kicked ahead.
Kelleway took the ball but the All Blacks counter-rucked and it was prop Ethan de Groot and lock Brodie Retallick who were positioned in the backline to feed Taukei'aho who had the power to score his second.
A superb lineout drive exposed the Australian defences and Gordon was sin-binned for collapsing a maul and from the resulting lineout the move saw Jordie Barrett feeding first five-eighths Richie Mo'unga who stepped his way across in the 51st minute.
Two minutes later Jordan took a Beauden Barrett chip kick and raced away from the chasing Australian defence for a 20th try, in his 20th Test.
Australia responded with penalties getting them into the All Blacks' 22m area. From a lineout, Foley in the midfield broke the line and fed Kelleway across.
Six minutes later, Kelleway benefited from another penalty lineout and the long pass from centre Len Ikitau put him in space for the try, to pull the score back to 27-31.
Mo'unga landed a penalty goal but Australia secured the ball from a Mo'unga kick and they moved the ball, worked the rucks and then freed it to Samu on the left flank. He broke a tackle, fed Marika Koroibete who fed back to Samu who scored.
The situation was not helped when replacement halfback Nic White slammed over a 50m penalty goal to give Australia a 37-34 lead with four minutes to play.
But the Australians felt they had secured the game when the All Blacks had kicked to the corner rather than the posts. However, Australia won a penalty at a breakdown after the maul but Reyand made his time-wasting decision and awarded the scrum to the All Blacks.
They moved the ball through Mo'unga, Jordan, who stepped, drew a tackle and then fed Jordie Barrett over in the corner.
Australia 37 (Rob Valentini, Andrew Kelleway 2, Pete Samu tries; Bernard Foley 4 con, 2 pen; Nic White pen) New Zealand 39 (Samisoni Taukei'aho 2, Richie Mo'unga, Will Jordan, Jordie Barrett tries; Mo'unga 4 con, 2 pen). HT: 10-10.