England 341 for 7 (Roy 114, Stokes 71*) beat Pakistan 340 for 7 (Babar 115, Hafeez 59, Fakhar 57) by 3 wickets
Roy's century laid the foundation but it was Stokes' rescue mission after England suffered a mini-collapse against Pakistan that delivered the hosts a three-wicket victory with three balls to spare at Trent Bridge and an unassailable 3-0 series lead.
Belligerent is a term at risk of being over-used in cricket but it is simply the essence of Roy's batting style and was there for all to see as he stepped back and away to club Mohammad Hafeez over the extra cover boundary to bring up his eighth ODI century.
His knock of 114 off 89 showed fewer signs of the rust he had to scrape off en route to 87 in the second match of the series in Southampton, his return from a back injury. On reaching his ton, Roy pumped both fists in triumph and looked to the skies, rolling his eyes in relief, as if that commendable 87 and the 79 that followed in Bristol were not enough.
However, when he was out edging behind a pull at Mohammad Hasnain, England's chase looked like being derailed.
England lost the wickets of Joe Root, Jos Buttler and Moeen Ali in quick succession, a collapse of 4 for 15, and it fell to Stokes - who had been rather subdued in recent times - to save the day. Stokes played with a cool head and, at the right times, a swinging bat to reach an unbeaten 71 off 64 balls.
He was well supported by Tom Curran, who followed his four wickets to be the pick of the England bowlers with an important cameo of 31 off 30. Before he got off single figures, Curran survived two run-out chances off the same ball, narrowly in the second instance with replays suggesting he may have been out had Pakistan made an issue of it.
Roy's innings was not chanceless. He was dropped by Fakhar Zaman off Imad Wasim while on 27 and with England 62 without loss. The mistake - not the only one in the field by Pakistan - proved costly.
James Vince, opening in place of the resting Jonny Bairstow, made a handy score without going on with it, his 43 off 39 balls coming during a stand of 94 with Roy. Root also chipped in but after he was out on the second grab by Hafeez in a tricky one-handed juggling effort over his shoulder off the bowling of Imad, England lost Buttler and Moeen for ducks.
Joe Denly, in the side as a back-up spin bowling prospect for the World Cup found himself in the role of potential batting saviour alongside Stokes. With England needing 101 off 80 balls the pair went into steadying mode, with the likes of Curran, Adil Rashid and Jofra Archer still available as testament to their formidable batting depth - with or without Bairstow and the suspended Eoin Morgan.
That depth was called upon, however, when Denly fell to a brilliant caught-and-bowled by Junaid Khan, the left-armer changing direction on his follow-through and leaping high to his right to pull down the ball and send Denly on his way for 17.
Needing 44 off the last five overs, Stokes and Curran looked comfortable but when Curran was bowled by Hasan Ali, England needed 22 off 16. A six and a four in Junaid's next over as good as settled things, before Stokes hit the winning run off Hasan.
Earlier, Babar Azam's steady-handed 115 off 113 balls helped Pakistan to 340 for 7.
Babar was involved in two century partnerships after Pakistan overcame the loss of in-form opener Imam-ul-Haq, who retired hurt on just 3 when he was struck flush on the left elbow attempting to pull a Mark Wood delivery in the fourth over. X-rays revealed no fracture but he remained in the changing-room with his arm packed in ice until late in the innings.
Fakhar and Babar steered their side to 116 before the first wicket fell to some good pressure from Curran. Looking to smack the ball over cover, Fakhar sent the ball to third man, where Wood claimed a good catch diving forwards.
Babar and Hafeez teamed up for the second century stand of Pakistan's innings, Hafeez cracking a boundary off Wood to bring up his half-century before Wood's response was to have him caught simply at mid-on by substitute fielder Chris Jordan for 59.
Babar brought up his century with a sweetly struck four off Curran, but he was out slicing the same bowler over cover as Archer ran in to take a fine catch.
When Imam returned with seven wickets down and only 16 balls remaining, he looked in some discomfort still and it begged the question whether it might have been wise to put in a batsman who could swing with more freedom, especially when he added just three more runs to his score.
Curran claimed 4 for 75 off 10 overs but looked gutted not to have bagged five wickets as he walked off.
Wood made an encouraging return to cricket, showing the pace and wicket-taking ability that heralded his initial comeback from an ankle injury in the Caribbean. Playing his first match since early March against West Indies, he hit 91.6mph in his first over here and ended with 2 for 71 off his 10 overs.