A relieved captain Kane Williamson called it one of the most remarkable Test finishes he had ever played in.
It was New Zealand's first series win over Pakistan since 1985 and a relieved captain Kane Williamson called it one of the most remarkable Test finishes he had ever played in.
"Without a doubt," he said, admitting he felt Pakistan had a chance to win when they started the final session needing 211 off 204 balls.
"You take nine wickets in a session, they're all pretty big moments... from the feeling at tea time to the feeling now is pretty contrasting and will go down as a great Test victory."
Pakistan were faced with an imposing 369-run target but set themselves up for a run-a-ball slog when they reached tea on the final day at 158 for 1.
At that stage Williamson began to question whether he had declared New Zealand's second innings too early at 313 for 5.
"It does cross your mind, but at the point of declaration we did know that the opposition needs a sniff," he said.
"They tried to chase it and we were able to get opportunities."
Pakistan captain Azhar Ali said they tried to pull out of the chase and play for a draw when Sarfraz Ahmed was run out to make it 199for 4 but they could not hold on.
"We thought that's it because the new ball" was due, he said.
"We did not want our lower order to be exposed to that but at the end if did happen and unfortunately we could not get the result we wanted."
The match edged towards a cliff-hanger finish before Tim Southee removed Pakistan's leading run scorer Sami Aslam for 91.
That started the collapse which saw eight wickets fall for 49 in 20 overs with Neil Wagner taking the final three for no runs in just six deliveries.
New Zealand's series win means Pakistan fall from second to fourth in the world rankings while New Zealand move up to sixth.
Pakistan were left to ponder whether they left their charge too late.
Azhar Ali (58 off 161 deliveries) and Aslam (91 off 238) laid the platform with a record Pakistan fourth innings opening stand of 131 but it lasted 60 overs before Azhar was dismissed.
The arrival of Babar Azam was a signal to lift the pace but the pitch was still offering support to the bowlers on the fifth day.
Azhar (58) played on trying to hit leg-spinner Mitchell Santner out of the ground and Azam (16) went in similar fashion fourth ball after tea.
Aslam, trying to raise the tempo having reached his highest Test score, mistimed a drive off Southee to Williamson at mid-off.
Sarfraz Ahmed was run out for 19 off 21 balls and Asad Shafiq did not get off the mark. Veteran Younis Khan, on his 39th birthday, struggled to 11 before he fell lbw to Southee.
Colin de Grandhomme snapped up Sohail Khan for eight before Wagner removed Mohammad Amir, Wahab Riaz and Imran Khan all without scoring.
It was a Test that had begun in Pakistan's favour after they won the toss on a lush green surface and celebrated with a wicket in the first over.
But that bright start faded rapidly and even the loss of more than four sessions to rain could save them.
Reaching 369 would have meant overtaking the record fourth innings chase in New Zealand of 348 for 5 by the West Indies 47 years ago in Auckland.