Dubai, United Arab Emirates: Pakistan spinners polished off New Zealand's top order to leave the Black Caps struggling at 167-6 for an overall lead of 177 runs after Sarfraz Ahmed hit a gallant century in the second test on Thursday.
Ahmed's brilliant 112 with 16 fours lifted Pakistan to 393 on the fourth day as he shared a record 81 runs with Rahat Ali for the last wicket stand and narrowed the Kiwis' lead to just 10 runs.
Zulfiqar Babar (3-60) and Yasir Shah (3-65) exploited the bowler's rough on both ends with some sharp-turning deliveries before Ross Taylor returned to form with an aggressive unbeaten 77 off 93 balls at stumps.
After his three disappointing knocks in the series Taylor dominated against both spinners, hitting 10 boundaries by mostly cutting it through point.
McCullum provided a rapid start of 42 runs before Shah won a contentious decision against first innings century-maker Tom Latham (9).
Latham immediately went for the television referral after he was caught in the leg slip, suggesting the ball had caught his forearm.
However, TV umpire Rod Tucker upheld the onfield umpire's decision as Latham walked off shaking his head in disappointment.
McCullum (45) took his tally of test runs to 5,451 to go second behind former skipper Stephen Fleming's New Zealand record of 7,172 before Babar and Shah struck three times within four overs after tea.
Babar removed Kane Williamson and won an lbw decision against McCullum through a television referral in his successive overs and in between Corey Anderson was clean bowled off Shah's sharp turner.
James Neesham (11) added 46 runs with Taylor before Babar once again crashed onto the stumps as the left-hander came out of his crease and the ball spun sharply from the rough.
New Zealand slipped further in the penultimate over with Shah dismissing BJ Watling before umpires called off the day's play due to bad light with 1.4 overs still remaining.
Resuming at 281-6, Tim Southee's (3-67) twin strikes had Pakistan reeling at 312-9 before Ahmed raised Pakistan's best 10th-wicket stand against New Zealand to the frustration of the Kiwis.
McCullum finally ended the agony when he caught and bowled Ahmed in the second over after lunch to get his first test wicket.
Ahmed and Ali improved the previous best 10th wicket partnership of 65 against New Zealand made by Salahuddin Ahmed and Mohammad Farooq at Rawalpindi way back in 1965.
Ahmed raced to his century by hitting spinners Mark Craig and Ish Sodhi for three boundaries each in back-to-back overs before cutting Southee to the point boundary to complete his century off 153 balls.
Ahmed was on 53 when Ali joined him but didn't panic despite Pakistan trailing by 91 runs. He mostly kept the strike to himself and exposed Ali for the last two deliveries during their gritty 28 overs of resistance.
Ahmed also became the first Pakistan wicketkeeper to have scored three test centuries in a calendar year after making 109 against Australia last month and 103 against Sri Lanka in August.
Pakistan leads the three-match series after an emphatic 248-run victory in the first test at Abu Dhabi last week.