Ben Stokes's unbeaten 71 rescued England from a top-order collapse as the World Cup hosts and favourites beat Pakistan by three wickets with three balls to spare at Trent Bridge.
Friday's win in a floodlit match saw England secure the series at 3-0 up with one to play but was far from routine.
England were cruising to a target of 341 at 201 for one when Jason Roy's dismissal for 114 sparked a collapse that saw three wickets lost for seven runs in 10 balls.
And when Moeen Ali was out for a duck, England had slumped to 216 for five.
But Stokes steadied the ship and Tom Curran got England back on track in a seventh-wicket stand of 61.
Surrey paceman Curran, pushing for a place in England's final 15-man World Cup squad, had already taken four for 75 in Pakistan's 340 for seven.
This was a modest score on a Trent Bridge ground where England have twice set the record for the highest one-day international total, with last year's 481 for six against Australia following their 444 for three against Pakistan in 2016.
And No 8 Curran demonstrated the depth of England's batting with a 31 featuring five fours.
But when he was yorked by Hasan Ali, England still needed 22 off 16 balls.
Stokes got the target down to 10 runs off 10 balls when he carved a six off Junaid Khan that just cleared Asif Ali at deep cover.
Adil Rashid's edged four past despairing Pakistan captain and wicket-keeper Sarfraz Ahmed left England requiring three off the last over to win.
Stokes finished the job with a single. The all-rounder faced 64 balls, with five fours and three sixes.
Roy, missed on 25 by Fakhar Zaman, and James Vince — selected in place of the rested Jonny Bairstow — put on 94 before
the Hampshire captain was bowled by teenage quick Mohammad Hasnain for 43.
Roy reached his eighth ODI hundred in style, lofting off-spinner Mohammad Hafeez over extra-cover for a fourth six in 75 balls faced.
But the 28-year-old couldn't see England home, gloving a hook off Hasnain to Sarfraz.
Test captain Joe Root (36) then edged left-arm spinner Imad Wasim to short third man where Hafeez held on at the second attempt.
England's 208 for three soon became 208 for four when stand-in captain Jos Buttler, who made 110 not out at Southampton last weekend before being rested for Tuesday's six-wicket win in Bristol, fell for a duck when he miscued a sweep off Imad to Hafeez at short fine leg.
Moeen Ali was also out for a duck, top-edging a sweep off Shoaib Malik with Fakhar Zaman, running back from mid-on, holding a tough catch.
Much of Pakistan's fielding was sloppy but left-arm quick Junaid reduced England to 258 for six off 40 overs with a superb right-handed caught and bowled off a slower delivery to dismiss Joe Denly.
Earlier, Pakistan failed to capitalise on Babar Azam's hundred.
Their innings fell away following a century stand between Babar, who made 115, and Hafeez (59).
Pakistan suffered a setback when Imam-ul-Haq, fresh from his career-best 151 at Bristol, had to retire hurt on three after missing an intended pull off an 89 mph ball from fast bowler Mark Wood that hit him on the elbow but X-rays showed no fracture.
Babar's 10th boundary, a leg-glance off Stokes, took him to his ninth hundred in 63 ODIs, and first against England, in 104 balls.
He then sliced Curran and Jofra Archer, running in from the cover boundary, held a well-judged catch.