Captain AB de Villiers pitched in with a fluent 52, but the innings looked to be faltering until Chris Morris (36 not out from 22 balls) joined David Miller (71 not out from 51 balls) in the 44th over.
England left Chris Woakes out as a precaution for the second Royal London Series one-day global against South Africa, recalling Jake Ball in his place. But it wasn't enough as Mark Wood prevented them from scoring the four runs needed off the final delivery.
Stokes smacked 101 - his second One-Day International century and joint-best score - off 79-balls as he punished the bowling in a blitz of big hits and aerial drives. But after arriving on the south coast for Saturday's match at the Ageas Bowl, South Africa's number-three batsman expects a significant improvement.
The bowler was, deservedly, Maharaj - who also had Alex Hales dropped.More news: Toronto CF Kevin Pillar apologizes for using anti-gay slur
More news: What Billy Horschel said after winning the Byron Nelson
More news: Chris Christie: I warned Trump about Flynn
South Africa hope to live up to their reputation as the world's top-ranked one-day worldwide side at Southampton on Saturday after blowing away "cobwebs" in their series-opening defeat by England.
Kagiso Rabada yorked Jason Roy in the fifth over with a delivery timed at 149.8 km/h, and 10 overs later England were 80/3.
Stokes, in his first England match since his most valuable player-winning stint in the lucrative Indian Premier League competition, came back on later Wednesday but did not bowl again.
Buttler (65no), who had a close umpire's call for lbw on eight, went on to hit four of five fours in one over off Phehlukwayo as he and Moeen Ali took England's predictable big finish to 111 in the last 10.