Australia’s win by five wickets levelled the three-match series to set up a decider in Cape Town on Wednesday.
Set a daunting 205 to win, Australia were in deep trouble at 32 for three after 5.4 overs.
But Warner (77) and Maxwell (75) thrashed the bowlers in a world record fourth wicket stand of 161 off 87 balls.
“They batted with great composure and played some great cricket shots,” said Australian captain Steve Smith.
“They summed up the situation really well.”
South African captain Faf du Plessis admitted: “That partnership blew us away.”
Du Plessis added: “There are small margins when two teams are playing good cricket. There were one or two things in the field that we could have done better. Two full tosses towards the end cost us.”
Both full tosses, by Chris Morris and Dale Steyn, were called no-balls, giving the batsmen free hits.
There was a twist in the tail, though, as Maxwell was caught off the fifth ball of the 19th over and Warner was yorked by Kagiso Rabada off the first ball of the final over.
James Faulkner and Mitchell Marsh got their side home to set up a series decider in Cape Town on Wednesday.
Two runs were needed off the last ball and Marsh was able to hit the ball past Rabada for the winning runs.
Man of the match Warner made 77 off 40 balls with six fours and five sixes, while Maxwell’s career-best 75 was scored off 43 balls with seven fours and three sixes.
Du Plessis anchored an aggressive South African batting performance, hitting 79 off 41 balls in a total of 204 for seven after they were sent in to bat.
Left-arm seamer Faulkner was outstanding for Australia, taking three for 28 in four overs while most of his team-mates took some heavy punishment.
Smith said at the toss that the Wanderers, a renowned limited overs batting paradise, was a ground where a batting team never knew how many runs were enough.
South Africa’s approach from the start suggested they believed they needed at least 200.
A succession of batsmen played big shots, scored quickly and got out, while Du Plessis played more circumspectly before slamming two sixes and two fours off the first four balls of the last over, bowled by John Hastings, before he was caught in the deep.
Du Plessis hit five sixes and five fours in a 41-ball innings.