South Africa gave themselves an outside winning chance in the second Adelaide Test 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 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, moving the ball through the air, 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 after scoring four in the first innings and a duck in Brisbane.
Nightwatchman Peter Siddle lasted 16 balls for his solitary run before he was caught behind off Morkel.
South Africa were dismissed for 388 at tea with debutant Du Plessis the last out for a fighting 78 while Jacques Kallis batted in pain for 58 to help his team avoid the follow on.
The world number one ranked Proteas had appeared to have little hope of passing the follow on of 351 runs, struggling at 250 for seven before a 93-run stand between Du Plessis and Kallis revived the South African innings.
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.
Australia sought a review after an appeal was turned down and replays showed that as Kallis was sweeping the ball struck his pad, then glove before popping in the air for wicketkeeper Matthew Wade.
It was Australia's morning with pacemen Siddle and Hilfenhaus sharing four of the wickets, including the prized scalp of Proteas skipper Graeme Smith for 122.
But the Australians had problems of their own when paceman James Pattinson left the field for scans on a side strain and was unlikely to bowl again for the rest of the game.
The Proteas resumed at 217 for two but quickly unravelled, losing three wickets in four overs.
Offspinner Nathan Lyon enticed Jacques Rudolph to drive only to be caught by Quiney at short cover for 29.
Siddle grabbed Smith's key wicket in the next over when the Proteas captain was caught behind by Matthew Wade for 122 off 244 balls.
Smith sought a referral which was upheld by the TV umpire much to the Proteas skipper's disgust after the review's Hot Spot infra-red imaging system detected a faint edge.
Smith has proved a lucky charm with his tons for South Africa. The Proteas have not lost the match in the previous 25 Tests in which he has scored a century.
Siddle struck again trapping AB de Villiers leg before wicket for one and Steyn (1) and Kleinveldt (0) were knocked over by Hilfenhaus.