Azhar, who opened the batting in place of the injured Imran Farhat on Saturday evening, was unbeaten on 27, eking out over 110 balls.
The only wicket to fall on Sunday morning was that of Younis Khan, who was caught at first slip off Dale Steyn in the seventh over of the day.
Farhat, who missed the start of Pakistan's follow-on innings after being struck on the right hand by Steyn in the first innings, joined Azhar and was slightly more adventurous in reaching 32 not out off 67 balls.
went for X-rays on Saturday afternoon which revealed no major damage.
Debutant Kyle Abbott, who destroyed Pakistan's first innings by taking seven for 29, was unable to repeat his success in a five-over spell on Sunday, although he troubled Farhat with several deliveries that bounced unpredictably outside the left-hander's off stump.