The hosts had started the day looking set for a battle to avoid defeat at nought for two when chasing a target of 319 following New Zealand's early declaration at 277-5 in their second innings.
After losing three more wickets ahead of lunch, a superb century from former captain Sarfaraz Ahmed, making 118 for a first Test hundred in eight years, helped turn Pakistan's innings around heading into the final session.
Pakistan needed 70 runs to win at the drinks break but Sarfaraz then fell in the 87th over, the last of spinner Michael Bracewell's four wickets, to halt their momentum.
Naseem Shah finished unbeaten on 15 and last man Abrar Ahmed was seven not out when bad light brought the match to an end, with Pakistan at 304-9 as the two-match series ended in successive draws.
The first Test, at the same venue, also saw an exciting climax when the visitors were 77 short of their 131-run target when bad light ended play on the final day.