Buttler was 66 not out and Bess 55 not out after the 20-year-old marked his Test debut with a fine fifty.
Pakistan play the second Test against England at Headingly.
Hasan Ali was caught by Jos Buttler at gully off Anderson without scoring, but Mohammad Amir survived to the close unbeaten on 19 with Mohammad Abbas (nought) and Pakistan will bid to increase their lead before attempting to bowl England out cheaply again on day three.
Dawid Malan (six) also fell to the combination of Hasan and wicket-keeper Sarfraz.
Trailing by 179 runs after the first innings, England slumped to 110-6 and Pakistan had a session to finish off the home side with two days to spare.
The visitors, who returned to England a year after clinching the magnificent ICC Champions Trophy, decimated the home team for a first innings total of 184 with Hasan Ali and Mohammad Abbas taking four wickets apiece.
Pakistan resumed on Friday with Azhar 18 not out and Haris Sohail 21 not out. Cook, playing in a record-equalling 153rd consecutive Test, was bowled by an excellent delivery from Mohammad Amir to end an innings lasting over three hours.
But shortly before tea he was bowled by Amir, a team-mate when Essex won the County Championship last season, as the left-arm quick produced a brilliant delivery that cut away late off the pitch late to clip the top of the opener's off stump.
Root, who could have been run out before he had scored, played carefully to get to four before driving rashly at a wide ball from Hasan to nick a catch to wicketkeeper Sarfraz Ahmed.
Stokes (9) then clothed Shadab straight to sub fielder Fakhar Zaman at midwicket before Abbas picked up the key scalp of Root lbw, the England skipper's review in vain with technology showing the ball, which nipped back off a good length, would have gone on to pelt leg stump.
Azhar completed a patient 133-ball fifty but was still on 50 when lbw to James Anderson, England's all-time leading Test wicket-taker.
But the work of team fielding coach Steve Rixon, the former Australia wicket-keeper, was rewarded when Asad Shafiq held a hard catch at second slip edge after Jos Buttler, recalled as a specialist number seven, edged a drive off Hasan and fell for 14.
Stuart Broad made his Test-best 169 against Pakistan at Lord's in 2010 - a match that became known for a spot-fixing "sting" that saw three Pakistan players, including Amir, jailed by an English court and given five-year bans by the International Cricket Council.