Victory left England 2-1 up in the four-match series ahead of next week's concluding Test at The Oval.
It also meant England had become the first team in 114 years of Test cricket at Edgbaston to win after conceding a lead of more than 100 runs batting first.
Pakistan, set a huge target of 343 for victory after England declared on 445 for six early on Sunday's final day, were dismissed for 201. Off-spinner Ali, who earlier in the day struck a quickfire 86 not out, sealed England's win when he caught and bowled tailender Sohail Khan.
Pakistan suffered a dramatic middle-order collapse shortly before tea as they lost four wickets for just one run in 23 balls. Pakistan were 124 for three when their slump started, with captain Misbah-ul-Haq (10) caught behind off Steven Finn to give the persevering fast bowler his first wicket of the series.
Asad Shafiq then completed a pair when he was plumb lbw to all-rounder Chris Woakes, bowling on his Warwickshire home ground, for a four-ball duck. It was the sixth time this series that paceman Woakes had taken a wicket in the first over of a spell.
Woakes then made it two for none in six balls when Sarfraz Ahmed was also out for nought as he edged to Joe Root at second slip. Sami Aslam, playing his first Test of the series, had again batted superbly for 70 following the opener's first-innings 82.
But a rare misjudgement by the 20-year-old left-hander saw him bowled by Finn as he deliberately left the ball.
It was the end of a more than three-and-a-half-hour innings of 167 balls, including 11 fours. Finn had now taken two for none in 11 balls and tea was put back by 15 minutes to see if England could finish the game.
But instead they had to content themselves with a session where they took six wickets for 79 runs. At tea, Pakistan were 148 for seven, with Yasir Shah seven not out and Mohammad Amir 15 not out.
With all their specialist batsmen dismissed, the question for Pakistan was could their tailenders somehow survive the remaining 28 overs to hold out for a draw. But five balls after the break, Shah edged James Anderson, England's all-time leading wicket-taker, to Alex Hales in the slips.
Pakistan were on the brink of defeat at 151 for nine when Amir drove Stuart Broad straight to Woakes at point. But a last-wicket stand of 50 in 67 balls between Sohail and Rahat Ali (15 not out) kept England at bay before Moeen Ali struck the clinching blow with 13.1 overs left in the day.
All five of England's frontline bowlers -- Anderson, Broad, Finn Woakes and Ali -- took two wickets apiece Sunday. Ali, who also made a first-innings fifty, was named man-of-the-match.
Pakistan's chase started poorly when Mohammad Hafeez (two) fell cheaply for the second time in the match before Aslam and Azhar Ali, who made 139 in the first innings, put on 73.
But Moeen Ali dismissed Azhar on 38 when he edged a loose drive to England captain Alastair Cook at second slip. Cook decided against declaring before the start of Sunday's play even though England had a lead of 311 runs.
Jonny Bairstow was 82 not out and Ali 60 not out after their century stand had taken the match away from Pakistan on Saturday. Birmingham-born Ali, who grew up near Edgbaston, struck 19 runs in the first over of Sunday's play from leg-spinner Shah, including two successive sixes.
Bairstow had added just one run to his overnight score when he was lbw to Sohail on review. Ali had faced just 96 balls, including 10 fours and two sixes, when Cook declared just four overs into Sunday's play.