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.
Azhar Ali (30 not out) ended the match by hitting Moeen Ali for a straight six as Pakistan finished on 42 without loss.
Sami Aslam was 12 not out as Pakistan bounced back from their 141-run defeat in the third Test at Edgbaston in style.
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.
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.
Ballance though was out for 17 when, playing carelessly away from his body, he was caught behind off Sohail Khan.
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.
But they lost two wickets in two balls soon afterwards to be 209 for eight.
Chris Woakes, backing up too far and deceived as Bairstow set off, was run out for a duck by bowler Wahab Riaz's direct hit on the non-striker's stumps.
Next ball, Bairstow chipped Riaz straight to Azhar in the covers to end a 127-ball innings featuring eight fours.
Bairstow has now scored 992 Test runs in 2016 and is in sight of breaking Zimbabwe great Andy Flower's record for most Test runs scored by a wicket-keeper in a calendar year of 1,045 set in 2000.
Shah, who took 10 wickets during Pakistan's 75-run win in the first Test across London at Lord's, enjoyed further success in the capital when Stuart Broad (five) reverse swept-him straight to Younis at first slip -- an extraordinary shot given England's position.
But with Riaz removed from the attack by the umpires for running on the pitch, England's last-wicket pair of Finn and James Anderson added 32 before Anderson was lbw, sweeping, to debutant off-spinner Iftikhar Ahmed.
England then saw fast bowler Finn leave the field injured after pulling up just two balls into the second over of Pakistan's chase with what appeared to be a hamstring injury.
Pakistan now travel to Ireland for two one-day internationals next week before returning to England for five ODIs and a Twenty20.