The right-handed batsman scored an unbeaten 111 for his third century -- all this year -- to take Pakistan to 392-9 at lunch, trailing by just 11 runs on New Zealand's first innings total of 403.
Sarfraz added a record 80 runs for the unfinished tenth wicket stand with Rahat Ali (16 not out) and even a 30-minute extension could not get New Zealand the last wicket.
Sarfraz hit three boundaries in one Mark Craig over and then two more off leg-spinner Ish Sodhi to come within four runs of his hundred.
He ran a full circle in jubilation, thumped his bat in the air to warm applause from his team-mates in the dressing room.
He has so far hit 16 fours in his 184-ball knock which evened the balance of the match.
It was Sarfraz, 28 overnight, who anchored the batting after Pakistan resumed the day on 281-6.
Paceman Tim Southee (3-67) removed Yasir Shah in the third over of the day, caught behind for two and just two runs later Trent Boult (2-69) trapped Ehsan Adil leg-before for nought, leaving Pakistan in danger of conceding a big lead.
Pakistan lead the three-Test series 1-0 after winning the first match by 248 runs in Abu Dhabi last week.
