New Zealand won the second Test against Pakistan after an extraordinary collapse in the final session that saw the tourists lose their last nine wickets for 71 runs.
Chasing a target of 369, Azhar Ali's side were 158-1 at tea - still 211 runs short of victory, before an inspired victory charge from New Zealand's bowlers as Pakistan became the first side in history to lose nine wickets in the final session of a Test match.
Neil Wagner (3-57) was the hero at the end as he dismissed Mohammad Amir (0), Wahab Riaz (0) and Imran Khan (0) in the space of six balls to complete a 138 run win to take the series 2-0 - the first time New Zealand had beaten Pakistan in a test series since 1985.
The touring side had started the day needing another 368 runs to win, though the stand-in captain Ali, and Sami Aslam didn't show much intent on chasing the target down in the first session as they reached lunch on 76 without loss.
Just prior to the interval New Zealand could have made their first breakthrough after an lbw appeal from Colin de Grandhomme was turned down, but Kane Williamson was too slow to ask for a review which eventually showed that Aslam would have been given out.
Still needing 293 runs to win at the start of the afternoon session, Ali and Aslam showed more intent after the restart with both players registering half-centuries as they extended their partnership to 131 for the first wicket.
Azhar (58) was the first wicket to fall after playing onto his stumps from a wide delivery from Mitchell Santner and Babar Alam (16) followed in identical manner to the same bowler after tea.
Aslam continued to push for boundaries and was nine runs short of a first Test century when he slapped Tim Southee (2-60) straight to Williamson at mid-off.
Sarfraz Ahmed was promoted to number four to help quicken the scoring rate and had moved to 19 from 21 balls when he was run out by Colin de Grandhomme's rocket arm from fine leg after pushing for a risky second run.
Williamson decided to take the second new ball straight away and that proved the catalyst for the late collapse as Matt Henry induced a leading edge from Asad Shafiq (0) to point in the 82nd over.
Younis Khan had scratched around for 11 from 44 balls before he padded up to a straight one from Southee and was given out on review.
Sohail Khan (8) then chipped de Grandhomme to cover before Wagner's devastating late spell swung the match decisively in New Zealand's favour to complete a remarkable victory at Seddon Park.