New Zealand secured a thrilling final-hour victory in the first Test against Pakistan to boost their hopes of making the World Test Championship final.
Spinner Mitchell Santner had last man Naseem Shah caught and bowled with just 4.3 overs left in Mount Maunganui.
The tourists began 71-3 needing to bat out the day for a draw or score 373 to win, and Fawad Alam hit 102, sharing a 63.2-over stand with Mohammad Rizwan.
Rizwan fell with 25 overs left before the hosts took the final five wickets.
Neil Wagner, who broke two toes on the second day, had Fawad caught behind to end his 269-ball, six-hour knock, which had seen the 35-year-old score his second Test century 11 years after his first.
Last pair Naseem and Shaheen Afridi survived seven overs in fading light before Santner finally broke their resistance, catching Naseem’s miscued drive one-handed above his head.
“It was a brilliant game,” New Zealand captain Kane Williamson said.
“Both teams put their best foot forward and Pakistan were incredibly resilient in that second innings, but the boys kept coming.
“A huge effort by the bowlers to get us across the line.”
Wagner’s wicket of Fawad came during a marathon 11-over spell late in the day.
“I just told him he’s mad,” said Rizwan, who was leading Pakistan with Babar Azam injured. “He’s a different guy. His attitude is everything, his aggression is very beautiful.”
New Zealand can go second in the World Test Championship table if they win the series 2-0. The top two teams will compete in the final at Lord’s next summer.
The Black Caps will also secure top spot in the International Cricket Council’s Test rankings if they win or draw the second Test, which starts on 2 January.