Victory meant England had an unbeatable 2-0 lead in the four match series here on Tuesday and had won their first home Test campaign against Pakistan since 1982.
England captain Andrew Strauss paid tribute to the bowlers.
"It was very high quality batting but the bowlers were magnificent," said Strauss.
"It's been ten days of really excellent test cricket. We've been working hard and those little things make a massive difference. Monty (Panesar) was outstanding today. He's done a brilliant job for us. It's not easy to contain world-class batsmen.
"Chris Read was excellent. He batted really well, very positively."
Pakistan, set 323 to win, were bowled out for 155 midway through the afternoon session.
They were in deep trouble at lunch having collapsed to 84 for five, still needing a further 239 for victory.
Paul Collingwood had run out Mohammad Yousuf, who scored 192 in Pakistan's first innings, for just eight before fast bowler Mahmood, took two wickets for no runs in three balls.
But two of Pakistan's star batsmen were still at the crease with man-of-the-match Younis Khan, who made 173 in the first innings, 29 not out and Pakistan captain Inzamam-ul-Haq unbeaten on nought.
And it was not long before Pakistan lost their sixth wicket
Monty Panesar, who'd already removed Taufeeq Umar (11), produced a classic left-arm spinner's delivery that pitched on middle and hit the top of off-stump to bowl Younis for 41 - the top score of the innings.
Then 112 for six became 113 for seven when Mohammad Sami, lingering in his crease before setting off, was run out for nought by Kevin Pietersen's throw to Mahmood.
Lancashire quick Mahmood then took two wickets in his first over back.
With the first ball of his second spell he had Shahid Nazir top-edging a hook to first slip Marcus Trescothick and then Umar Gul edged low to Collingwood at third slip to leave Pakistan 149 for nine.
Mahmood's final analysis was an impressive 8-2-22-4.
Inzamam himself was last man out, stumped by wicket-keeper Chris Read for 37 off Panesar, who finished with three for 39 from 17.5 overs.
Danish Kaneria was nought not out.
Matthew Hoggard, on his Yorkshire home ground, had made the initial breakthrough when he Salman Butt (16) edging to first slip Trescothick.
Pakistan, who resumed on nought without loss, then saw 23 for one become 68 for three.
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 Umar caught at silly point by Alastair Cook off a bottom-edged bat/pad sweep.
England then captured the prize wicket of Yousuf, who'd added 363 with Younis in the first innings, a Pakistan record for any wicket against England.
After Younis played the ball behind square, Yousuf failed to beat Collingwood's direct hit from gully, the pair putting on a mere 16 this time.
England, 1-0 up in the series after their innings and 120 run second Test win at Old Trafford, were now on top.
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 he was well caught by a diving Read off Mahmood and two balls later wicket-keeper Kamran Akmal went for nought after getting a thin edge to a 90mph (150kph) delivery which Read safely held.
Even before they'd started their run chase, history was against Pakistan.
The most they'd 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 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.
Pakistan captain Inzamam-ul-Haq said: "I was encouraged after the first inning fightback and thought we could go on and win, but England bowled well."
Younis Khan added: "We had a little bit of trouble in the opening. We tried to stay positive all the time but they bowled very well."
The fourth Test starts at The Oval on August 17.