Mohammad Abbas was next to depart after being run out on one following a comical mix-up with Ali, who was attempting to retain the strike.
Anderson (5-56), who had claimed his fourth wicket of the innings in the opening session, completed his 29th five-for in Tests when he enticed Naseem Shah (0) to edge to Dom Sibley at third slip to wrap up the Pakistan innings.
Play was stopped due to bad light before Pakistan could bat again, with the visitors trailing by 310 runs.
Anderson, England’s highest Test wicket-taker, is now two wickets away from becoming the first pace bowler to claim 600 Test dismissals.
Only spin bowlers Anil Kumble (619), Shane Warne (708) and Muttiah Muralitharan (800) have more dismissals in the game’s longest format.
Zak Crawley (267) converted his maiden century into a double ton and shared a record-breaking 359-run partnership with Buttler (152) as England declared their first innings on 8-583 on Saturday.
England, who hold a 1-0 lead, are edging towards their first Test series win over Pakistan since 2010.
The hosts won the opening match in Manchester by three wickets, and the rain-hit second game ended in a draw.