Opener Jeet Raval was unbeaten on 17 with three boundaries while Tom Latham was five not out.
With the Dubai stadium pitch starting to turn ace leg-spinner Yasir Shah could be the key to Pakistan gaining a big first innings lead.
New Zealand, who lead the series 1-0 after a narrow four-run win in the first Test in Abu Dhabi last week, still trail by 394 runs with all ten wickets intact.
Sohail improved on his previous best of 110 scored against Australia at the same venue last month while Azam passed his previous best of 99, against Australia in Abu Dhabi last month.
He added an invaluable 186 runs for the fifth wicket with Azam as the two frustrated the New Zealand’s attack in the first two sessions.
The Pakistani batsmen added 82 between lunch and tea, scoring faster than in any of the pervious sessions.
Sohail took 309 balls to reach three figures and then waved his bat toward the dressing room, apparently pointing to his team-mate Azhar Ali, run out after a mix-up with Sohail on Saturday.
He was finally dismissed soon after tea, caught behind off paceman Trent Boult. In all he faced 421 balls and hit 13 boundaries.
Azam ably supported Sohail and hit 12 boundaries and two sixes. He added 58 for the sixth wicket with skipper Sarfraz Ahmed who made 30 not out.
Azam said it was a big relief gettint to the first hundred after falling for nervous nineties.
“It’s a big relief to score first century,” said Azam. “Since my childhood I used to hear that scoring a Test hundred is above everything so it was a dream to score a hundred in a Test.
“We are in a good position and if we get early wickets tomorrow in the first session then we would be able to get a good lead and then go on to win the Test.”
Medium pacer Colin de Grandhomme finished with 2-44 while Boult and left-arm spinner Ajaz Patel took a wicket apiece.
Pakistan, resuming at 207-4, needed a big partnership to put pressure on New Zealand and Sohail and Azam responded well.
Medium pacer Colin de Grandhomme has figures of 2-44 while left-arm spinner Ajaz Patel, who took seven wickets in the first Test, has taken one wicket for 91.
The third and final Test is in Abu Dhabi from December 3.
Inkakavala is your news, entertainment, music fashion website. We provide you with the latest breaking news and videos straight from the entertainment industry.