South Africa posted 204 for seven on a flat batting wicket and were on top when they reduced the tourists to 32-3 in their reply.
Yet Warner (77 from 40 balls) and Maxwell (75 from 43) staged a remarkable fightback with a Twenty20 Australian record partnership for any wicket of 161 to take their side close to victory.
Needing two from the final delivery of the innings from seamer Kagiso Rabada, Australia's Mitchell Marsh bludgeoned the ball down the ground and was able to scramble the runs his side needed to level the three-game series at 1-1.
Warner and Maxwell's stand fell just short of the world record of 171 set by New Zealand's Kane Williamson and Martin Guptill against Pakistan in January.
The pair were particularly severe on leg-spinner Imran Tahir and seamer David Wiese, who went for 105 in their combined eight overs.
The only consolation for South Africa was the successful return of fast bowler Dale Steyn (2-32 from four overs), who is trying to prove his fitness ahead of the World Twenty20 in India, which starts on Tuesday.
The home side's innings was anchored by Faf du Plessis, who smashed 79 from 41 balls, with fine cameos from Quinton de Kock (44) and David Miller (33).
James Faulkner proved the pick of the Australian bowlers with 3-28 from his four overs.
The final match of the three-game series will be played in Cape Town on Wednesday.
REUTERSA record stand from David Warner and Glenn Maxwell helped Australia to secure a five-wicket victory over South Africa.
Original source: Warner and Maxwell lift Australia