Pakistan went into the lead on the second day of the First Natwest Test match against Pakistan at Lord's.
Ali and Haris Sohail began the session brightly, both happy to drive when given the chance, and they looked increasingly assured as the morning went on.
Stuart Broad clearly made a conscious effort to pitch the ball up to the bat and despite failing to make an early incision into the Pakistan batting line up, had impressive control as he found movement both ways.
Anderson struggled for his best form, though, and his first spell only lasted three overs before Joe Root pulled him out of the attack and replaced him with Mark Wood.
The Durham paceman immediately found some sharp pace and following a spell of short-pitched bowling, caught Haris on the crease and induced an outside edge which Jonny Bairstow caught expertly.
Asad Shafiq began his innings in positive mood but had to watch on as Ali, who made exactly 50, was pinned LBW by the returning Anderson.
Shafiq wasn't perturbed, however, and put Bess over the midwicket boundary in the final over before Lunch to move on to 28 not out.
Anderson had new batsman Babar Azam dropped at first slip upon the resumption, Alistair Cook failing to grasp a tough chance low to his right, before Shafiq went passed 50 with an uppercut for four.
As the partnership approached 100, and Azam his half-century, Pakistan went into the lead with England searching desperately for a way back into the game.
That opening came soon after when Stokes produced a snorting bouncer which Shafiq (59) could only parry to the slip cordon.
On the stroke of Tea, Stokes claimed another wicket when luring Pakistan captain Sarfraz Ahmed into a misjudged hook shot which was well pouched by Wood at fine leg.
Pakistan went into the break on 227-5, still leading by 43, but were dealt a significant blow shortly afterwards when Azam was forced to retire hurt on 68 having been struck a nasty blow on the arm by another Stokes short ball.
Still, they extended their lead beyond a hundred without further losses as England toiled in the evening, until Anderson bowled Faheem for 37 via an inside edge from one that nipped back.
That left Pakistan on 318 for six - a lead of 134.
Shadab became the fourth Pakistan batsman to go past his half-century when an attempted pull off Stokes took a top edge and bounced to safety, despite the best efforts of the onrushing Bairstow.
He was dismissed three balls later for 52, though, as another lifter from Stokes was gloved down the leg side and taken by Bairstow.
Hasan Ali lasted just two balls as a rearing delivery from Anderson took the shoulder of the bat and flew to Buttler at gully.
Pakistan closed on 350 for eight to lead by 166 runs heading into the third day at Lord's.
- live updates from the first Test match Lord's