Azhar Ali and Asad Shafiq hit centuries to leave Pakistan in command of the third and final Test against New Zealand in Abu Dhabi despite a batting collapse that curtailed its first-innings lead.
Azhar hit an attractive 134 for his 15th Test hundred while Shafiq scored 104, but debutant New Zealand off-spinner Will Somerville took four wickets to restrict Pakistan to 348 all out.
Pakistan appeared set to build a huge lead before collapsing from 286-3 to lose its final seven wickets for the addition of just 62 runs.
The 34-year-old Somerville finished with 4-75 while left-arm spinner Ajaz Patel took 2-100 and pace spearhead Trent Boult chipped in with 2-66.
That gave Pakistan a 74-run lead -- the same advantage it held in the first Test at the same venue before losing by four runs.
New Zealand was then reduced to 26-2 at stumps with Kane Williamson unbeaten on 14 and nightwatchman Somerville on one not out to leave the side trailing by 48 runs with eight wickets intact.
READ: Team India announces 12-man squad for opening Test against Australia
Paceman Shaheen Shah Afridi trapped Jeet Raval for nought while leg-spinner Yasir Shah had Tom Latham caught for ten, his 199th wicket in Tests.
Yasir needs just one more wicket to become the fastest to 200 wickets, in his 33rd Test, a record currently held by Australian leg-spinner Clarrie Grimmett who reached the milestone in 36 Tests, 82 years ago.
Shafiq said Pakistan must limit New Zealand in its second innings after his side failed to chase down 176 in the first Test.
“It's always nice to bat with Azhar,” said Shafiq. “But it was disappointing that we couldn't get a big lead. It happens in cricket and you have to give credit to the bowlers.
“We need to get them out quickly tomorrow so that we don't need to chase a lot of runs.”
Azhar and Shafiq put on 201 for the fourth wicket, but once they were dismissed only Sarfraz Ahmed (25) and Babar Azam (14) offered some resistance.
Azhar edged medium pacer Colin de Grandhomme through the slips to complete his first century since May 2017 against the West Indies in Dominica - and his first hundred against New Zealand.
ALSO READ: India vs Australia: Kohli taking nothing for granted
He took 210 balls to reach the three-figure mark, before being caught sweeping off Somerville, just before tea.
Shafiq brought up his 12th Test ton with a sharp single off Somerville before falling leg-before to Patel to a straight delivery.
Somerville then had Azam and Hasan Ali (nought) bowled and wrapped up the innings by getting Sarfraz caught at mid-wicket.
Earlier, Azhar and Shafiq frustrated New Zealand's search for early wickets as they took Pakistan to 224-3 at lunch.
New Zealand skipper Williamson took the second new ball in the 81st over with Pakistan comfortably placed at 213-3, but the bowlers struggled to extract much life from a flat pitch at the Sheikh Zayed Stadium.
Pakistan levelled the series with an innings and 16-run win in the second Test in Dubai.