Pakistan need 274 runs on the final day to win the second Test and complete a 2-0 series sweep against New Zealand after bowling the hosts out for 293 late on the fourth day.
Umar Gul ripped through New Zealand's tail, taking two wickets in two balls, as the hosts lost four wickets for seven runs late on Tuesday.
Last man Chris Martin faced Gul's hat-trick seeking delivery and kept it out with a French cut behind square to the enormous cheers of the small crowd at the Basin Reserve.
Tim Southee then smashed two sixes as he tried to push the lead closer to 300, before Gul had Martin caught behind for one. Southee ended 22 not out, while Gul finished with four for 61.
Pakistan had threatened to smother New Zealand's attempts to build a target that the home side's bowlers could then defend on the final day.
The game was disrupted for 23 minutes in the final session when rain forced the players off the field. They returned after 16 minutes but in comical scenes were then forced to turn and run for cover as another downpour swept across the ground.
Just as the ground staff had laid the first covers over the pitch, the rain just as quickly stopped and the players returned seven minutes later.
New Zealand suffered a blow in their quest for quick runs when the aggressive Jesse Ryder was bowled for 17 on the first delivery after the rain delay when he did not play a shot at a straight ball from part-time off-spinner Mohammad Hafeez.
James Franklin (six) also fell to Hafeez when he edged a ball to Younus Khan before Ross Taylor (52) and Reece Young (20)combined for a 60-run partnership that helped extend the lead before they both fell with the score at 268.
Young was caught in close by Azhar Ali, off Rehman, while Taylor was trapped in front by Gul, who then bowled Vettori for one and trapped Brent Arnel for a duck to set up the hat-trick opportunity.
Brendon McCullum and Martin Guptill had put on 120 for the first wicket -- only the second century-opening stand by New Zealand since 2004 -- to provide the perfect launch pad to attack Pakistan in the afternoon sessions.
McCullum was caught by Tanvir Ahmed off Rehman when his lofted shot came off the toe end of his bat for 64 shortly after lunch and their momentum stalled as Pakistan bowled short of a length and set defensive fields to stymie the scoring rate.
The hosts lost two quick wickets just before tea when Kane Williamson nicked a Tanvir delivery to Akmal for 15 with the score on 166 and was immediately followed by Guptill for 73 when he was trapped in front by Rehman.
Pakistan had been bowled out for 376, a first-innings advantage of 20 runs, late on Monday. They hold a 1-0 lead in the two-match series and are seeking their first Test series victory since 2006.
New Zealand first innings (356)
Pakistan first innings (376)
New Zealand second innings (overnight 9-0)
B McCullum c Tanvir b Rehman 64
M Guptill lbw b Rehman 73
K Williamson c Akmal b Tanvir 15
R Taylor lbw b Gul 52
J Ryder b Hafeez 17
J Franklin c Younus b Hafeez 6
R Young c Azhar b Rehman 20
D Vettori b Gul 1
T Southee not out 22
B Arnel lbw b Gul 0
C Martin c Akmal b Gul 1
Extras: (nb-13, w-1, b-2, lb-6) 22
Total: (all out, 90.5 overs) 293
Fall of wickets: 1-120, 2-166, 3-166, 4-192, 5-208, 6-268 7-268, 8-275, 9-275, 10-293.
Bowling: Gul 20.5-4-61-4 (w-1, nb-4), Tanvir 10-0-36-1 (nb-3), Rheman 39-6-119-3, Wahab 8-1-38-0 (w-6) Hafeez 13-3-31-2.