Joe Root hit his second successive century for England but again finished on the losing side after an astonishing assault by South African all-rounder Chris Morris squared the series at the Wanderers Stadium on Saturday.
South Africa won the fourth one-day international by one wicket to set up a series decider in Cape Town on Sunday.
Man-of-the-match Morris, dropped on 14 when South Africa were eight down and still 52 runs short of victory, slammed 62 off 38 balls.
Adil Rashid, the man who dropped Morris — a straightforward chance at mid-off from the bowling of Reece Topley — was brought on to bowl with the scores level and bowled Morris with a googly. But last man Imran Tahir punched the next ball square for the winning boundary.
That the match went so deep seemed unlikely when England were floundering at 108 for six after being sent in to bat.
But Root made 109 and steered England to a total of 262.