Perth: Australia will have to produce the greatest run chase in Test history to beat South Africa in the third Test at the WACA Ground and claim the top spot in the Test rankings.
Set 632 to win after the Proteas were finally dismissed for 569 in their second innings on the back of Hashim Amla and AB de Villiers centuries, Australia were 40 without loss at stumps on the third day on Sunday.
The Australians still need a further 592 runs to win with two days to play.
David Warner will resume on Monday's fourth day on 29 with Ed Cowan not out nine.
It was only the second time in Test history Australia had been set over 600 runs to win. The previous occasion was Don Bradman's first Test against England in 1928, when they folded for 66 all out chasing 742 runs.
The current record for a successful fourth innings run chase remains 418 by the West Indies against Australia at St John's in 2003.
Tall fast bowler Morne Morkel threw a major scare in the South African camp when he appeared to roll his left ankle in his delivery stride late in the day.
Morkel was on the pitch for several minutes, but just when it seemed the Proteas may be down to two fast bowlers, Dale Steyn and Vernon Philander, the big man picked himself up and finished his over without apparent discomfort.
Amla led the way for the Proteas with the bat and looked certain to notch a third Test double century, but on 196 he fell to a superb reflex caught-and-bowled from Mitchell Johnson (4-110).
The right-hander had a lucky escape on 108 when Mike Hussey dropped a tough chance in gully off Johnson, but he was in total command for most of his innings, his dismissal ending a 149-run partnership with de Villiers for the fourth wicket.
It was Amla's 18th Test century and he faced 221 balls, hitting 21 boundaries.
After resuming at 99 not out on the third day, Amla took just three balls to reach triple figures, having faced a mere 87 balls.
At one stage, retiring Australian batsman Ricky Ponting was even given a bowl as Amla and de Villiers took the game away from the Australians.
De Villiers reached his 14th Test century in memorable fashion just before tea, audaciously reverse-sweeping spinner Nathan Lyon for three successive boundaries to reach the milestone.
He eventually fell for 169 as he appeared to tire, caught behind from the bowling of Mitchell Starc, having faced 184 balls, hitting 21 fours and three sixes.
South African Dean Elgar completed a nightmare Test debut, being trapped lbw by Johnson for a four-ball duck to complete a pair for the match.
Left-armer Starc cleaned up the South African tail to claim his first five-wicket haul in Test cricket and finish with six for 154 from 28.5 overs.