South Africa gave themselves an outside winning chance in the second Test in Adelaide with five Australian wickets late on the third day on Saturday.
The Australians, leading by 162 runs after the first innings, were sailing along at 77 without loss before a tumble of wickets gave the Proteas renewed heart with two days left.
At the close, Australia were 111 for five with first innings double centurion Michael Clarke on nine and century-maker Mike Hussey not out five. That gave the home side a lead of 273 with five wickets left.
Rory Kleinveldt bowled his team back into the contest with three wickets in 18 balls and Dale Steyn and Morne Morkel grabbed one each to add an edge to the contest.
South Africa had been facing the possibility of a huge run chase. The biggest successful chase at the Adelaide Oval was 315, which Australia achieved to overhaul England in 1902.
Swing bowler Kleinveldt struck with two wickets in three balls, getting David Warner to miscue to Faf du Plessis at cover for 41 and then dismissing Rob Quiney for his second duck, nicking to wicketkeeper AB de Villiers.
Kleinveldt picked up his third wicket when he bowled Ed Cowan for 29.
Ricky Ponting's miserable series continued when he chopped Steyn on to his stumps for 16 and nightwatchman Peter Siddle made just one before he was caught behind off Morkel.
South Africa were dismissed for 388 at tea with debutant Du Plessis the last out for 78 while Jacques Kallis batted in pain for 58 to help his team avoid the follow on.
Du Plessis faced 159 balls and hit 13 fours and a six before he was caught by Clarke at silly mid on off Ben Hilfenhaus.
Kallis, batting at number nine after spending most of Thursday's opening day off the field with a hamstring injury, scored a crucial half-century off 93 balls before he was caught behind off left-arm spinner Clarke.