The Australian openers, debutant Aaron Finch and Usman Khawaja then saw off 13 overs remaining in the day rather comfortably with the surface still playing well.
Leading a scandal-hit team dismissed as Australia's worst in 30 years, captain Tim Paine's pledge to win back hearts and minds seemed a fanciful, if noble, aspiration in the leadup to the test series against Pakistan.
"We know that to become a good team, we first have to be hard to beat", Paine said.
"It was an extremely tough Test match", said Paine, after his second Test as captain.
"He's a bit of a triple threat - he's great in the field, he bowls some really handy legspin which I think will surprise some people and he's a really skillful, talented batsman".
Australia have also recalled Peter Siddle and will want him to combine with Starc to generate a formidable pace attack to support Lyon.
Khawaja, though, looked more steady than he historically has in Asia, and will look to kick on tomorrow on what is still a pitch you'd rather bat than bowl on.
'I am really happy to score this hundred and helping the team, ' said Hafeez.
Finch, who played 93 one-day internationals for Australia before earning his first test cap, showed patience and restraint in accumulating 59 from 139 balls, including five boundaries and a six.
Pakistan, who were 45 for three overnight, declared 7.5 overs after lunch on 181 for six at the fall of Asad Shafiq's wicket for 41. Sohail and Imam had added 65 runs for the fourth wicket. He took 24 wickets in three Tests in a series win over Sri Lanka a year later.
A 33-year-old Pakistan debutant has realised Australia's worst fears, with Bilal Asif ripping through the tourists middle order after a strong start.
Two balls later Abbas had the elder Marsh caught behind and in his next over trapped Mitchell right in front of the stumps only to get the decision on review.
"I could have been doing something else (had I retired)", said Hafeez after putting on a solid 205-run opening stand with Imam-ul-Haq who made a career best 76.