Paceman Shaheen Shah Afridi trapped Jeet Raval for a nought while leg-spinner Yasir Shah had Tom Latham caught for ten, his 199th wicket in Tests. Yasir now 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 after the day's play asserted that Pakistan must limit New Zealand in their 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.
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.