Roy gave the hosts the perfect start to their pursuit of 341, cracking 114 in 89 balls before four wickets tumbled quickly to put the result in the balance and left Stokes to shoulder the burden.
The all-rounder stood tall in a nervy finale, timing his run perfectly to finish with an unbeaten 71 and holding his nerve as Pakistan crumbled with a sequence of dismal fielding errors.
— England Cricket (@englandcricket) May 17, 2019
A three-wicket victory left England 3-0 up with one to play, still unbeaten this summer and with a high-pressure triumph under their belts.
Stokes flicked the winning run with three balls remaining but Pakistan will know they should have gone closer, overthrows, misfields and the failure to appeal for a run out against Tom Curran all undermining their efforts.
Curran had earlier taken four wickets to show his worth with ball in hand, while Babar Azam will feel unlucky to be on the losing side after a hard-fought 115.
With Jonny Bairstow rested, stand-in opener James Vince made a decent fist of his latest opportunity, making a pleasing 43 before bailing out of a big swing and playing on.
Roy, on the other hand, was destined for bigger things as soon as a mis-hit off Imad Wasim evaded the flapping Fakhar Zaman with his score on 25. The next ball disappeared for four and the pattern was set.
A top edge took him past 50 but there was no shortage of inspired hitting as Roy took just 32 balls to convert his century.
There were three notable sixes: an impudent ramp over fine leg that left Junaid Khan aghast, a meaty square pull and then a fleet-footed skip to leg that allowed just enough room to bludgeon into the crowd at cover. That stroke ensured his eighth England ton but the fun was soon over, feathering Hasnain softly down leg.
Pakistan seized their moment, making Roy's the first of four wickets in 17 balls. Wasim took a prize pair, Joe Root off a clunky outside edge and Jos Buttler for an improbable duck, caught off the back of the bat attacking a full toss.
Moeen Ali found himself elevated to five but lasted just three balls.
Stokes and Joe Denly shaved 42 runs off the target before the latter fell to a one-handed return catch by Junaid Khan, whose fielding had verged on risible for most of the evening. That left exactly 10 overs remaining and 83 to get.
Curran made 31 of them after a life on six, short of his ground when a successful run out attempt failed to catch the attention of Sarfraz Ahmed or the umpires, but Stokes it was who owned the decisive moments.
The Pakistan innings was built around successive century stands led by Babar, 107 with Fakhar and 104 alongside Mohammad Hafeez.
That placed the tourists well at 220 for one and, although they were still able to add another 120 runs from the last 80 balls of the innings, the loss of six batsmen punctured their momentum.
Opening bowlers Jofra Archer and Mark Wood had earlier become instant contenders for the country's quickest ever new-ball pairing, both men easing beyond the 90mph barrier.
Wood, bowling competitively for the first time in more than two months, wasted no time in making his mark on Imam-ul-Haq, who retired hurt after a nasty looking blow on the left elbow. The pain was palpable moments after impact, as the batsman leapt in discomfort and hit the turf.
That aside, it was attritional stuff for the home attack, with just two breakthroughs in 39 overs. Curran claimed the first, Fakhar well held by the sprawling Wood at third man for 57, and the Durham man returning to hurry up Mohammad Hafeez after a frantic but effective turn worth 59.
It was the lowest score of a high-scoring series but England's consistent ability to go one better than their opponents is becoming an increasingly useful habit.