Victory saw Pakistan end the four-match series all square at 2-2 on an Oval ground where they won their first Test match in England back in 1954.
England, 88 for four overnight, were dismissed for 253 in their second innings, with Shah taking five for 71 in 29 overs after Jonny Bairstow top-scored with 81.
That left Pakistan needing just 40 to win after excellent hundreds by man-of-the-match Younis Khan (218) and Asad Shafiq (109) had helped them compile a commanding first-innings total of 542.
Pakistan remain third in the world Test rankings but, following this win, could rise to number one if results in Sri Lanka and the West Indies go their way.
More From This Section
England resumed in trouble at 88 for four, 126 runs adrift, after Shah had ripped through the top order with three for 15 late on Saturday. Gary Ballance was four not out and Jonny Bairstow 14 not out.
New batsman Moeen Ali had frustrated Pakistan with a first-innings 108 and shared a partnership of 93 with Bairstow. But Ali fell for 32 when he went back defensively to Shah and got a thin edge which wicket-keeper Sarfraz Ahmed held at the second attempt to end a stand of 65.
England were 194 for six at lunch, still 20 behind, with Bairstow 70 not out.