England's inexperienced pace attack toiled tirelessly in the thankless second session, but even their spinners were unable to break through the resilient Pakistani duo.
Masood was batting on 130, his fifth test hundred, at the break while opener Shafique was on 94.
Pakistan did not start well though and opener Saim Ayub tickled a Gus Atkinson delivery down the leg side to be caught behind in the fourth over of the day.
Masood, then on 16, was given lbw to Brydon Carse in the debutant seamer's second over but the batter reviewed the decision and got it overturned after replays confirmed the ball had pitched outside the leg stump.
Masood went on to take two runs off Atkinson to race to a 43-ball fifty.
Shafique got a reprieve on 35 when he went for a risky single and England's stand-in captain Ollie Pope's direct throw narrowly missed the stumps.
He stepped out and hit spinner Shoaib Bashir for a six to bring up his fifty.
Masood played nearly at a run-a-ball rate and took a single off Chris Woakes to bring up his first test hundred since August 2020.
England's regular captain Ben Stokes missed the test with a hamstring injury.
This article was generated from an automated news agency feed without modifications to text.
Stay informed with the...