Having been set 373 to win, Pakistan was 71-3 still 301 runs behind and the New Zealand bowlers who had dismissed Pakistan for 239 in its first innings to give the home side a 192-run lead, still held the upper hand.
Pakistan finally was out for 271 at 6.36 p.m. local time with fewer than five overs left in the day's play and a draw beckoning.
Left-arm spinner Mitchell Santner dismissed No. 11 batsman Naseem Shah to clinch the win after Naseem and Shaheen Afridi had defied New Zealand for almost eight overs as the number of balls remaining in the day dwindled.
"There was a huge effort from the bowlers to get us across the line but a lot of credit goes to Pakistan for the way they fought in that second innings, New Zealand captain Kane Williamson said. For all money it was going to be a draw until late in the piece.
"We were lucky to be on the right side of the result when we were up against a very tough side."
The final day didn't unfold in quite the way New Zealand had hoped or even begun to expect when Trent Boult dismissed the overnight batsman Azhar Ali (38) in the second over of the day.
The early blow seemed to make a quick resolution more likely.
But Fawad Alam and Mohammad Rizwan, who came together when Azhar was out, took the script New Zealand had conceived for the day and almost turned it on its head.
Far from capitulating quickly, the fifth wicket pair established a magnificent partnership under pressure and led one of the finest acts of resistance a New Zealand test has produced on its last day.
In conditions which were never congenial for batting the ball still occasionally reared from a length or jagged from a crack in the Bay Oval pitch in Mount Maunganui they batted through all of the first two sessions and into the last to fuel Pakistan's hopes a draw.
There were a minimum of 90 overs to be bowled when the day began, more than enough for New Zealand to achieve the seven wickets in needed for a draw. For the batting side, a long day stretched ahead and an effort an effort of enormous character would be required to survive the day.
A Pakistan win likely was off the table even at the start. With more than 300 runs needed for victory on a wearing day pitch, an attempt to reach the winning target likely would have wise.
Instead, Fawad and Rizwan put on 165 for Pakistan's fifth wicket. More importantly, they defied the New Zealand bowlers for 285 minutes almost five hours taking Pakistan into the final session with six overs still intact.
At that point the match seemed in the balance. New Zealand had taken only one wicket Azhar's in the first two sessions and that had become a remote memory when the last session began.
Fawad and Rizwan's stand had begun to seem impregnable.
They had assembled a 50 partnership from 132 balls, their century stand from 270, 150 runs together from 328. Throughout the day there were moments of alarm or danger when the ball beat the edge or grazed the stumps. But the pair batted on and on and their endurance lifted Pakistan's spirits.
Fawad, who bats out of an unorthodox full frontal stance with his back to his stumps and almost directly facing the bowler, was still able to produce a full array of shots. He reached his half century from 149 balls early in the second session, then his century richly deserved his 102 coming from 236 balls with 14 boundaries.
It was his second century in only his sixth test.
Rizwan, whose 71 in the first innings helped Pakistan avoid the follow-on, posted his second half century of the match, 60 runs from 156 deliveries.
New Zealand finally made the breakthrough and separated the pair near the middle of the final session when Kyle Jamieson trapped Rizwan lbw. His appeal was declined by the on-field umpire but upheld under review.
Fawad followed quickly for 102, caught by wicketkeeper B.J. Watling from the bowling of Neil Wagner, still laboring with two broken toes.
Jamieson removed Yahir Shah (0) and Wagner dismissed Faheem Ashraf (19) who had top-scored in the first innings with 91 and was the last recognized batsman. Santer trapped Mohammad Abbas (1) lbw.
Naseem and Shaheen rattled New Zealand's nerves with their late partnership but Santner finally broke through, dismissing Naseem caught and bowled.
"I'm not disappointed, that's the beauty of test cricket," said Rizwan, who captained Pakistan for the first time. "The New Zealand team did more hard work than us so they deserved to win.
(Only the headline and picture of this report may have been reworked by the Business Standard staff; the rest of the content is auto-generated from a syndicated feed.)
Business Standard has always strived hard to provide up-to-date information and commentary on developments that are of interest to you and have wider political and economic implications for the country and the world. Your encouragement and constant feedback on how to improve our offering have only made our resolve and commitment to these ideals stronger. Even during these difficult times arising out of Covid-19, we continue to remain committed to keeping you informed and updated with credible news, authoritative views and incisive commentary on topical issues of relevance.
We, however, have a request.
As we battle the economic impact of the pandemic, we need your support even more, so that we can continue to offer you more quality content. Our subscription model has seen an encouraging response from many of you, who have subscribed to our online content. More subscription to our online content can only help us achieve the goals of offering you even better and more relevant content. We believe in free, fair and credible journalism. Your support through more subscriptions can help us practise the journalism to which we are committed.
Support quality journalism and subscribe to Business Standard.