The touring side bowled England out for 253 in their second innings, Shah completing figures of 5-71, before Azhar Ali and Sami Aslam eased them to a simple target of 40 in 13.1 overs to complete an emphatic win.
England had resumed on 88 for four and Gary Ballance soon fell for 17 but Jonny Bairstow and Moeen Ali shared a sixth-wicket partnership of 65 to give the hosts hoping of saving the match.
Shortly before lunch, however, Shah deceived Moeen with a quicker delivery and the left-hander, on 32, nicked another catch to a gleeful Sarfraz.
Chris Woakes was run out following a mix-up with Bairstow, who drove the next delivery from Wahab Riaz straight to extra cover, his departure for 81 ending any realistic chance of England saving the match.
Azhar smashed Moeen for a huge six to take Pakistan to 42/0 and clinch victory, punching the air in delight before leaving the field with Aslam to warm applause from the sun-baked crowd.
Pakistan won the first Test at Lord's and England were victorious in Manchester and Birmingham.