At lunch Pakistan, needing 323 to level the four-match series at 1-1, were 84 for five - still requiring a further 239 for victory on Tuesday.
But two of their star batsmen were still at the crease with Younis Khan, who made 173 in the first innings, 29 not out and Pakistan captain Inzamam-ul-Haq unbeaten on nought.
However, only the tail remained behind them.
Matthew Hoggard made the breakthrough when, having seen Salman Butt strike him for six fours on his way to 16, he had the left-hander flat-footedly edging a drive to Marcus Trescothick at first slip.
Pakistan, who resumed on nought without loss after surviving a Hoggard maiden late Monday, then saw 23 for one soon became 68 for three.
Left-arm spinner Monty Panesar, who led England's attack with three for 127 in the first innings, then struck in the second over of his spell when he had Taufeeq Umar (11) caught at silly point by Alastair Cook off a bottom-edged bat/pad sweep.
England then captured the prize wicket of Yousuf, who scored 192 in the first innings and added 363 with Younis, a Pakistan record for any wicket against England, while he was still in single figures.
Wicket-keeper Chris Read had failed to cling on to an edged cut off Panesar when Yousuf was on four.
But after Younis played the ball behind square on the offside, Yousuf failed to beat Collingwood's direct hit from gully and was run out for eight.
England, 1-0 up in the series after their innings and 120 run second Test win at Old Trafford, were now on top.
And pace bowler Mahmood then strengthened England's position, with two wickets falling on 80.
Inzamam's prolonged absence Monday with a chest injury meant he could not bat higher than number seven.
So Faisal Iqbal took his skipper's number five slot. But on 11 Iqbal was well caught by a diving Read off the rapid Mahmood and two balls later wicket-keeper Kamran Akmal went for nought after getting a thin edge to a 90mph (150kmp) delivery which was safely held by his opposing gloveman.
The most Pakistan had previously scored in the fourth innings to win a Test was the 315 for nine they achieved against Australia at Karachi in 1994/95.
And only two sides in history had made more than 300 batting in the fourth innings to win a Test at Headingley with a Don Bradman-inspired Australia posting 404 for three back in 1948 and England, thanks to a Mark Butcher century, scoring 315 for four against Australia five years ago.
England's second innings 345 owed much to captain Andrew Strauss's 116 while Read, recalled for this match after Geraint Jones was dropped because of a lack of runs, made a valuable Test-best 55.