Hafeez was trapped leg-before wicket by seamer Ben Stokes for 98 in the last over before tea after England toiled hard on a flat Sheikh Zayed Stadium pitch.
Hafeez and Malik, unbeaten on 72 at tea, added 168 for the second wicket to bolster Pakistan's innings after Misbah-ul-Haq won the toss and decided to bat.
Hafeez hit 13 boundaries during his 170-ball knock before attempting to play on the leg-side in an attempt to reach his ninth Test hundred. He challenged Australian umpire Paul Rieffel's decision but to no avail.
Anderson pitched one short to Masood who took his eyes off the ball as it hit the grill of his helmet and fell onto the stumps.
More From This Section
Anderson was then unlucky not to have Hafeez as Ian Bell dropped a regulation catch off the bat in the second slip. Hafeez was then batting on seven.
Hafeez took advantage of the lapse and at 26 hit leg-spinner Adil Rasheed to point boundary to reach 3,000 runs in his 45th Test. He is the 17th Pakistani batsmen to score 3,000 or more runs in Tests.
Malik, playing his first Test for five years, also had a reprieve when on 40 he was caught in the gully off paceman Stuart Broad only to see umpire signalling a no-ball.
He has so far knocked eight boundaries in his ninth Test fifty, his first against England in five Tests.
Pakistan were forced to leave out leg-spinner Yasir Shah who was ruled out of the match with a back problem.
The 29-year spinner, seen as match-winner for Pakistan, stumbled while bowling in the nets on Monday and after assessment early Tuesday was left out.