England secured a 1-1 series draw with South Africa as they beat the hosts by two wickets in the third one-day international in Johannesburg.
Recalled spinners Adil Rashid (3-51) and Moeen Ali (1-42) helped restrict the Proteas to 256-7 despite Quinton de Kock and David Miller both hitting 69.
Jason Roy (21) and Jonny Bairstow (43) got England off to a fast start before the tourists stuttered.
Joe Root (49) and Joe Denly (66) played maturely to stabilise the chase.
But South Africa fought back with four quick wickets in a tense finale before Moeen and Chris Jordan guided England to 257-8 with 40 balls to spare.
While the chase should never have been so tight, it was an improved performance from the world champions after they were beaten by seven wickets in the first ODI, with the second match abandoned because of rain.
England will next face South Africa in three Twenty20 internationals, with the first match in East London on Wednesday.
- TMS podcast: Rashid returns to spin England to victory
- Reaction to England’s win in third ODI
Seasoned spinners and young seamers impress
After giving needed experience to all-rounder Sam Curran and leg-spinner Matt Parkison in the first two matches, England recalled Moeen and Rashid, with both spinners demonstrating their ongoing value to this side.
Moeen, making his first international appearance since taking a break after the first Ashes Test in August, showed superb control and bowled Rassie van der Dussen shortly after the South African was controversially able to overturn being given out lbw off Rashid.
Rashid offered constant threat, with several batsmen unable to pick his googly, in snaring Temba Bavuma and Andile Phehlukwayo lbw and duping De Kock into a loose shot to bowl the Proteas captain.
The accuracy of Moeen and Rashid through the middle overs ensured South Africa never got close to an overwhelming total, even when the impressive Miller (69 not out) attacked poor death bowling from Jordan, who conceded 40 off his last three overs.
It remains to be seen whether England will move on from Moeen and Rashid by the next World Cup in 2023, but there were also promising performances from two young seam bowlers England hope will feature.
Saqib Mahmood, 22, had a fine ODI debut in taking 1-17 off five overs, bowling Reeza Hendricks with a beautiful delivery that just grazed the top of the bail.
And 24-year-old Tom Curran, an unused member of the 2019 World Cup-winning squad, troubled the Proteas’ top order and gave up just 38 runs from his nine overs.
Nervy ending after composed chase
Bairstow showed brutal power and purpose to punish loose bowling by seamer Ngidi, smashing flat sixes over square leg, crashing anything over-pitched through the covers and punching adeptly down the ground.
He looked on course for a big score only to miscue one off a thick inside edge to mid-wicket before fellow opener Roy, who hit two sixes over long on, was also caught off a misjudged shot.
England could have wobbled when captain Eoin Morgan tamely chipped straight back to Beuran Hendricks (3-59) for nine, but Root played the fuss-free innings he excels at to stabilise the chase while keeping on top of the rate.
He was livid at his dismissal after tapping left-arm wrist-spinner Tabraiz Shamsi to leg slip, where Bavuma took a sublime low catch, but Denly continued the calm accumulation.
As England closed in on the target, Denly hit Shamsi for back-to-back sixes over mid-wicket to bring up his second consecutive ODI half-century only to loft a drive to Phehlukwayo off Ngidi (3-63).
South Africa surged back into the contest by taking three more wickets for just 20 runs, as Banton was caught behind for 32, Curran skied one to cover and Rashid nicked behind, but Moeen kept calm to ensure England avoided a first ODI series defeat since 2017 in India.
Test Match Special commentator Simon Mann at the Wanderers
Morgan revealed before the game that some players would only be playing here to get match practice before the T20 series – Rashid was one of them.
He’s bowled very little this winter – he’s had a shoulder problem – but you wouldn’t have known it given how he bowled on Sunday.
He was a threat throughout his spell. He came on at 80-1 after 18 overs and turned the game decisively England’s way. South Africa’s right-handers seemed unable to read him and, on another day, he could easily have taken another five-wicket haul.
He gives England potency in the middle overs – they looked a completely different side from Cape Town when he was rested.
Rashid’s dropped catch off Chris Morris at the Wanderers four years ago cost them the series. Here, his bowling ensured they didn’t lose another one.
‘We need to develop ruthlessness’ – reaction
England captain Eoin Morgan: “We bowled really well – Adil and Moeen came in and showed their value. Adil in particular, his control and variation were outstanding.
“It was disappointing to limp over the line. Ideally we would have chased it four or five down. We would have liked to win commandingly.
“Tom Banton showed lot of promise, Joe Denly’s two knocks were really good, Saqib came in and bowled beautifully, and likewise Parky [Matt Parkinson] in the first game. We showed a lot of promise but we need to develop our ruthlessness.”
England’s Adil Rashid, who took 3-51: “I felt good. It has been a while since I played and I was eager to get out there. The ball came out nicely – it was nice to play on a spicy wicket with turn and bounce.”
South Africa captain Quinton de Kock: “We gave ourselves a sniff at the end and it was cool to make it tough for the England guys.
“Being captain takes a lot of getting used to, but the guys help me a lot on and off the field. The energy of our players stood out for me.”