WELLINGTON: 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 just about kept it out with an inside edge behind square to the 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 4-61.
"Everyone in the changing room is incredibly excited about what tomorrow brings," New Zealand opener Brendon McCullum told reporters.
"To be able to turn up on the fifth day of a test match not knowing whether you're going to win or lose and having the opportunity to win is pretty exciting.
"Where this team is at the moment, I think you'll see a really desperate show from us tomorrow."
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 when Jesse Ryder (17) and James Franklin (six) fell to part-time off-spinner Mohammad Hafeez.
Ross Taylor (52) and Reece Young (20), however, 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.
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.