Pakistan's Saud Shakeel and Imam-ul-Haq hit fighting half-centuries on Sunday to foil England's seam and pace attack and set up an exciting finish to the second Test in Multan.
Set a challenging 355 runs for victory, Pakistan ended the third day at 198-4, needing another 157 with two full days remaining.
With reverse swing helping the fast bowlers, England derailed Pakistan's start of 66 without loss with three wickets for just 17 runs.
But Haq (60) and Shakeel (54 not out) led a remarkable 156-minute fightback during their stand of 108 for the fourth wicket before Leach had the former caught at slip three overs before stumps.
Haq, who came in at number five instead of opening the innings following hamstring treatment, hit seven boundaries.
Allrounder Faheem Ashraf, promoted to number six, was three not out as Pakistan chased a series-levelling win after losing the first of three Tests by 74 runs in Rawalpindi.
Pakistan can take heart from the fact that their highest successful chase was 377 against Sri Lanka in Pallekele in 2015, and they beat the same opponents after being set 342 in Galle in July.
No team has ever successfully chased more than 314 in Pakistan, a target reached by the home team against Australia in Karachi in 1994.
After Pakistan's solid start, veteran pacer James Anderson bowled Mohammad Rizwan with the fifth ball after lunch for 30, before Ollie Robinson dismissed skipper Babar Azam for one.
Azam was left shell-shocked as he tried to leave a ball which came in sharply to hit the stumps.
It became 83-3 when Mark Wood bowled Abdullah Shafique for 45 with a ball that reverse-swung to hit the stump and beat a forward push.
Earlier, spinner Abrar Ahmed took 11 wickets for 234 across the two innings -- the second best by a bowler on debut for Pakistan, behind Mohammad Zahid's 11-130 against New Zealand in Rawalpindi 26 years ago.
Harry Brook top-scored with 108 in England's 275 all out.
He smashed spinner Mohammad Nawaz for his 14th boundary to complete his second century of the series, having notched 153 runs in the first Test.
He also struck a six before being caught off spinner Zahid Mahmood, who took 3-52.
England resumed at 202-5 and added 73 runs before folding an hour before lunch.
Ben Stokes made 41 and added 101 for the sixth wicket with Brook before England lost their last five wickets for just 19 runs.
Ahmed's second innings figures were 4-120.
The final Test is in Karachi from December 17.
Pakistan vs England 2nd Test scoreboard
Scoreboard at stumps on the third day of the second Test between Pakistan and England at Multan Cricket Stadium on Sunday:
England 1st innings 281 (B. Duckett 63, O. Pope 60; Abrar Ahmed 7-114)
Pakistan 1st innings 202 (Babar Azam 75, Saud Shakeel 63; J. Leach 4-98)
England 2nd innings (overnight 202-5)
Z. Crawley run out 3
B. Duckett b Ahmed 79
W. Jacks b Ahmed 4
J. Root c Shafique b Ahmed 21
H. Brook c Shakeel b Mahmood 108
O. Pope run out 4
B. Stokes c Ali b Nawaz 41
O. Robinson b Ahmed 3
M. Wood c Azam b Mahmood 6
J. Leach not out 0
J. Anderson lbw b Mahmood 4
Extras: (nb2) 2
Total (all out, 64.5 overs) 275
Fall of wickets: 1-11 (Crawley), 2-25 (Jacks), 3-79 (Root), 4-147 (Duckett), 5-155 (Pope), 6-256 (Stokes), 7-259 (Robinson), 8-270 (Wood), 9-271 (Brook)
Bowling: Ali 9-0-44-0 (nb2), Ashraf 5-2-12-0, Ahmed 29-3-120-4, Nawaz 10-0-42-1, Mahmood 10.5-1-52-3, Salman 1-0-5-0
Pakistan 2nd innings
Abdullah Shafique b Wood 45
Mohammad Rizwan b Anderson 30
Babar Azam b Robinson 1
Saud Shakeel not out 54
Imam-ul-Haq c Root b Leach 60
Faheem Ashraf not out 3
Extras (lb2, nb3) 5
Total: (for four wkts, 64 overs) 198
Still to bat: Agha Salman, Mohammad Nawaz, Zahid Mahmood, Abrar Ahmed, Mohammad Ali
Fall of wickets: 1-66 (Rizwan), 2-67 (Azam), 3-83 (Shafique), 4-191 (Haq)
Bowling: Robinson 10-3-14-1 (nb3), Leach 20-0-88-1, Root 13-2-36-0, Wood 11-0-35-1, Anderson 6-1-8-1, Jacks 4-0-15-0
Toss: England
Umpires: Marais Erasmus (RSA) and Aleem Dar (PAK)
TV umpire: Joel Wilson (WIS)
Match referee: Andy Pycroft (ZIM)