At the break Kane Williamson was not out on 135 and Ross Taylor was in on 26 as New Zealand led by 37 runs.
Brendon McCullum scored a brilliant 202 with 21 boundaries and 11 sixes before he was bowled by leg-spinner Yasir Shah.
He added a new second wicket record for New Zealand in Test cricket of 297 runs with Williamson.
Pakistan lead the three-match series 1-0 after winning the first Test in Abu Dhabi and drawing the second in Dubai. (AFP)