Birmingham: Azhar Ali's century helped keep England at bay before he was out to the final ball of the second day of the third Test at Edgbaston on Thursday.
Azhar's more than six-hour 139, his 10th Test century but first outside Asia, ended when all-rounder Chris Woakes, on his Warwickshire home ground, struck with the new ball to have him edging to England captain Alastair Cook at first slip.
That left Pakistan 257 for three at stumps, 40 runs behind England's first innings 297.
Number three Azhar had come in just five balls into Thursday's play after Mohammad Hafeez had fallen for a duck to leave Pakistan none for one.
Azhar punished England for dropping him twice with his 10th century in 48 Tests.
Together with recalled opener Sami Aslam, who made 82, he put on 181 for the second wicket.
Aslam, a 20-year-old left-handed opener, was in sight of a well-deserved maiden Test hundred when he was run out responding to Azhar's poor call.
Younis Khan was 21 not out, having helped Azhar add 76 for the third wicket.
"The last ball is always nervy — it was a loose shot," Azhar told Sky Sports.
"But I'm really pleased that I got a hundred today.
"The reputation is we don't perform in English conditions and you want to prove that wrong."
England's tough day in the field was made worse when James Anderson was twice warned officially in one over by Australian umpire Bruce Oxenford for running on the pitch in his follow-through.
One more such warning and Anderson, England's all-time leading Test wicket-taker, would be barred from bowling again in the innings.
Anderson lost his temper in particular with Joel Wilson when the West Indian on-field umpire gave him an initial, if not formal, caution about running on the pitch.
"I've apologised for my behaviour to the umpire," said Anderson. "I was probably a bit out of order."
He added: "We bowled pretty well. We kept them at three-an-over for most of the day.
"All credit to the Pakistan guys at the top of the order — they played really well."
Hafeez fell for a duck after lazily guiding a short Anderson delivery to Gary Ballance at point.
Pakistan had seen Sohail Khan, one of their two changes from the side that suffered a 330-run thrashing at Old Trafford as England levelled the four-match series at 1-1, take a Test-best five for 96 on Wednesday.
Now the spotlight was on Aslam, also playing just his third Test, after he had replaced struggling fellow left-handed opener Shan Masood.
Aslam's only prior innings this tour was his 17 against Worcestershire during last week's two-day warm-up match.
Yet the well-organised Aslam played with a composure belying his years.
Pakistan were still on their lunch score of 72 for one, with Azhar on his interval total of 38 not out, when the right-hander's flashing drive off Anderson was dropped by Joe Root at second slip.
Azhar's cover-driven three off fast bowler Steven Finn saw him to a 129-ball fifty, including six fours.
Meanwhile Aslam swept off-spinner Moeen Ali for four, to complete a maiden Test fifty in 135 balls with five boundaries.
Azhar almost fell to Ali on 68, but the bowler was unable to hold a return chance above his head off a hard-hit drive.
After tea, both Azhar and Aslam drove Ali for a straight six apiece.
But with England on the ropes, a self-inflicted wound saw Aslam run out.
Azhar poked Woakes into the offside and set off for a non-existent single, with the luckless Aslam dismissed by James Vince's direct hit from cover.
Pakistan were now 181 for two, with Aslam having faced 176 balls in a stad spanning 62 overs.
This innings comfortably surpassed Aslam's previous Test-best of 20 against Bangladesh in Khulna last year.
Azhar's ungainly pulled four off paceman Stuart Broad saw him to his second Test century against England in 209 balls.
In what has become a familiar sight this series, the 31-year-old Azhar celebrated with several press-ups — a tribute to the Pakistan Army staff who helped prepare the squad during a pre-tour 'boot camp'.