Opener Hafeez, who returned to the side after missing the second Test due to injury, was unbeaten on 178 with captain Misbah-ul-Haq on 38 not out.
With Pakistan leading 1-0 in the series, Misbah had no hesitation in opting to bat after winning the toss on a slow surface at the Sharjah Cricket Stadium.
Hafeez, whose top score in Tests is 196, and Shan Masood (12) put on 44 for the opening wicket before the latter was bowled by off-spinner Mark Craig in his first over.
Right-handed Hafeez, who had scored 96 and 101 in the first Test in Abu Dhabi, then added 87 for the second wicket with Azhar Ali (39) before Craig broke the stand.
Hafeez was, however, unperturbed and hit Craig for two consecutive boundaprewwdries to reach 99 before calmly picking up a single off the next ball to reach his seventh Test ton. He has so far hit 23 boundaries and three sixes in his 262-ball knock.
In the morning, the 34-year-old survived a barrage of bouncers from all-rounder Corey Anderson, who was not afraid to use the short ball a day after Australia cricketer Phil Hughes suffered a severe head injury while batting in Sydney.
Younis Khan (five) was out leg before to former New Zealand captain Daniel Vettori, who made his return to the Test arena as the visitors used a trio of spinners for the series-decider.
The 35-year-old Vettori, who had not played a Test since July 2012 due to injuries, replaced all-rounder James Neesham from the starting team that drew the second Test in Dubai.
Misbah, dropped on 20 by wicketkeeper BJ Watling, added 121 for the unbroken fourth wicket with Hafeez and kept Pakistan on course for a big first innings total.
Image: Mohammad Hafeez
Photograph: Warren Little/Getty Images