Skipper Kane Williamson cracked an unbeaten century as New Zealand took a valuable 198-run lead against Pakistan on day four of the third and final test in Abu Dhabi on Thursday.
Williamson was not out on 139 off 282 balls having batted through the day, with middle-order batsman Henry Nicholls keeping him company on 90 as New Zealand reached 272-4 at stumps to swing the deciding test in their favour.
The teams are tied 1-1 in the three-match series.
Shah fastest to claim 200 Test wickets
Resuming on their overnight score of 26-2, New Zealand lost nightwatchman William Somerville in the seventh over of the morning as the debutant was trapped in front of the wicket by leg-spinner Yasir Shah.
Shah's fifth wicket of the contest in his 33rd test saw him replace Australian Clarrie Grimmett as the fastest man to claim 200 test victims.
Grimmett, also a leg-spinner, had reached the 200 mark in his 36th test against South Africa 82 years ago.
Pace bowler Shaheen Shah Afridi then had Ross Taylor caught at square leg as the veteran batsman looked to pull one away, but that was as much joy as Pakistan would have on a Sheikh Zayed Stadium track that has steadily improved for batting.
After coming together at 60-4, Williamson and Nicholls rode their luck to put on an unbroken 212-run stand for the fifth wicket.
Shah in particular was guilty of poor fielding, dropping Williamson on 80 and 106, while Imam-ul-Haq missed a sharp catch after left-hander Nicholls reached his fifty.
Pakistan tightened up to lower the scoring rate but could not stop Williamson from completing his 19th test century and Nicholls from inching closer to his third.
New Zealand won the opening test in Abu Dhabi by four runs before Pakistan squared the three-match series with victory in the second test in Dubai by an innings and 16 runs.