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 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.
More From This Section
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.
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 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.
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.