Quinton de Kock and Hashim Amla ensured that South Africa remain alive in the series as they both came together to put on a massive double century opening partnership apart from scoring individual hundreds and defeat England by 7 wickets at SuperSport Park on Tuesday.
Joe Root made a career-best 125 as England posted a competitive 318 for eight after winning the toss.
England captain Eoin Morgan admitted: "I certainly thought at half-time that we would win the game."
But De Kock and Amla made the target look easy as they put on 239 for the first wicket.
De Kock in particular was in majestic form as he made 135 off 117 balls, with 16 fours and four sixes before he hit leg-spinner Adil Rashid, England's best bowler, to Root at mid-off.
Amla went on to make 127 before flashing at a wide ball from Chris Jordan to be caught behind with just eight runs needed.
South Africa won with 22 balls to spare. England lead the five-match series 2-1, with matches in Johannesburg and Cape Town to come.
South African captain AB de Villiers praised an "unbelievable" effort by De Kock and Amla but said he was always confident South Africa could win.
"We were up for it today," said De Villiers.
"There was urgency in the field and a bit of hunger. I would have bowled first. Quite a few of us come from here and we know it is difficult to defend here at night."
Root made his 125 off 113 balls with ten fours and five sixes, scarcely playing a false stroke.
He shared a second wicket partnership of 125 with Alex Hales, who made 65 off 73 balls, and 82 for the fifth wicket with Ben Stokes, who slammed 53 off 37 balls.