Pakistan lost two wickets without scoring on the fourth day of the second Test in Karachi after New Zealand set them a target of 319.
Skipper Tim Southee dismissed opener Abdullah Shafique with the a ball that kept low before Ish Sodhi spun through nightwatchman Mir Hamza’s defences in the last over of the fourth day.
At the close, a shocked Imam-ul-Haq was at the crease without scoring and the home team needing 319 runs for victory, or eight wickets in hand to hold out for a draw.
A loss would be their third series defeat at home in a season after going down 1-0 to Australia and 3-0 to England earlier this year.
No team has chased more than 314 to win a Test in Pakistan, which the home team set against Australia in Karachi 1994.
New Zealand declared their second innings ten minutes before close on 277-5 after Michael Bracewell hit a career-best 74 not out and Tom Blundell 74.
The pair turned the match during their match-turning 127-run fifth wicket stand.
Pakistan had the match under control when they had New Zealand struggling at 128-4 from 76-1 at lunch, removing Tom Latham (62), Kane Williamson (41) and Henry Nicholls (five).
But Blundell, dropped on 21 by wicketkeeper Sarfaraz Ahmed off spinner Abrar Ahmed, punished the home team with seven boundaries and a six before holing out off Agha Salman.
Bracewell, whose previous best of 49 was against England earlier this year, was also dropped on 59 by Sarfaraz off Salman.
In the post-lunch session New Zealand lost three wickets in the space of 50 balls and 14 runs.
Latham was smartly caught off a miscued flick at short mid-wicket by Abrar Ahmed from fast-bowler Naseem Shah.
With the total unmoved on 114, in the next over Ahmed trapped Williamson leg-before. Hasan Ali had Nicholls caught soon after as New Zealand lost three wickets off 50 balls for 14 runs.
Field umpires Alex Wharf and Aleem Dar had a horrible day with three of their decisions overturned.
New Zealand were jolted in the second over of their innings when Mir Hamza bowled Conway with his first delivery.
It was the first time Conway fell without scoring in his 12-match Test career.
Pakistan wasted two leg-before referrals on Williamson when the batter was on seven and nine, while Latham overturned a decision against him on 36 -- all off Ahmed.
At the start of the day, Pakistan were dismissed for 408 after adding just one run to their overnight score, in response to New Zealand's 449 first-innings total.
Spinner Ish Sodhi had last man Ahmed trapped leg-before for nought, leaving centurion Saud Shakeel stranded on the other end.
Shakeel was unbeaten on 125 after a marathon resistance-packed 493 minutes at the crease, hitting 17 boundaries in his maiden hundred.
Spinner Ajaz Patel finished with 3-88 and Sodhi 3-95.
The first of the two-match series -- also in Karachi -- ended in a draw.
Scores in Brief
New Zealand (1st innings) 449 all-out, 131 overs (Devon Conway 122, Tom Latham 71, Matt Henry 68 not out, Tom Blundell 51, Kane Williamson 36, Ajaz Patel 35, Henry Nicholls 26; Abrar Ahmed 4-149, Naseem Shah 3-71, Salman Ali Agha 3-75) and 277-5d (Tom Blundell 74 not out, Michael Bracewell 74, Tom Latham 62, Kane Williamson 41; Mir Hamza 1-38, Hasan Ali 1-39, Salman Ali Agha 1-42, Naseem Shah 1-43)
Pakistan (1st innings) 408 all-out, 133 overs (Saud Shakeel 125 not out, Imam-ul-Haq 83, Sarfaraz Ahmed 78, Salman Ali Agha 41, Babar Azam 24, Shan Masood 20; Ajaz Patel 3-88, Ish Sodhi 3-95) and 0-2 (Tim Southee 1-0, Ish Sodhi 1-0)