Pakistan were 200 for 8 at lunch on the third day, trailing New Zealand by 71 when rain forced the players from the field 10 minutes early.
The 22-year-old Azam, in only his third Test, was not out 81, surpassing his previous Test best of 69 on debut against the West Indies last month.
Mohammad Amir was 4 not out with only Imran Khan left to bat.
After starting the day on the ropes at 76 for 5, Pakistan added 124 in 31.4 overs during the session, which began 30 minutes early to make up time lost to rain on the first day.
Also Read
Ahmed had luck on his side when he pulled Tim Southee to midwicket where the ball went through the hands of a leaping Henry Nicholl.
Four balls later Tom Latham missed with a shy at the stumps as Ahmed slipped mid wicket after being turned back during an aborted single attempt.
Bowling with a blustery wind behind him, Southee could not reproduce his commanding form of Saturday when he removed the Pakistan top order and bowled just three overs on Sunday in an intial spell that cost 32 runs.
Southee came back to find a better line in his second spell to remove Sohail, caught behind by wicketkeeper BJ Watling.
Wahab Riaz faced only five balls before he was lbw to Colin de Grandhomme.
Southee has taken 4 for 68 and Wagner three for 59.
Disclaimer: No Business Standard Journalist was involved in creation of this content