South Africa’s JP Duminy and Dean Elgar both scored centuries in a third-wicket partnership of 250 to drive the tourists to a 388-run lead over Australia at the end of the third day of the first test on Saturday.
Australia removed both centurions around the tea break, as well as Temba Bavuma and captain Faf du Plessis in the last hour, but by then the damage had been done and the Proteas will go into day four on 390 for six.
Quinton de Kock, who was dropped by Adam Voges on one, was at the crease unbeaten on 16 at the end of a long, hot day at the WACA, along with Vernon Philander, who had made 23 not out.
South African paceman Dale Steyn was ruled out of the rest of the series with a fractured shoulder on Friday and will play no further part in the match, reducing the number of wickets Australia need to take.
Steyn was a member of the Proteas team that chased down 414 to beat Australia at the WACA in 2008 but it was a debutant Duminy who scored the three runs off Mitchell Johnson that got the South Africans over the line.
Now 32, Duminy looks to have played a key role in another Perth triumph after his brilliant 141 rammed home South Africa’s advantage after they had skittled Australia for 244 in reply to their 242 on Friday.
Duminy faced 225 balls and hit 20 of them for fours with another going for six, overhauling partner Elgar before lunch and reaching his fifth test century with two runs to deep cover soon after the break.
It was his first century in two years and his third against Australia, just reward for a masterclass of calm control and shot-making.
The end came just as it looked like the pair of left-handers would bat through to tea, Peter Siddle benefiting from a DRS review when the technology revealed a nick off the bat that carried through to wicketkeeper Peter Nevill.
Elgar did not have such a good experience on his previous visit to the WACA, having got a pair when he made his test debut at the ground in 2012, albeit on the winning team.
Dogged and determined where Duminy was fluent, the 29-year-old reached his fifth test century half an hour before tea after a prolonged spell in the “nervous nineties”.
His career-best 127 came off 316 balls and he had hit 17 fours and one six when Josh Hazlewood finally winkled him out after tea when he offered a tired shot and got an edge which Mitchell Starc took at gully.
Starc should have caught Elgar on 81 when the batsman skied the ball to mid-off but he lost the ball in the Perth sun, tripped himself over trying to readjust his position and spilled it on the turf, to the despair of bowler Nathan Lyon.
The left-arm paceman also accounted for Du Plessis (32), a fine edge taken behind by Nevill, while Hazlewood had Bavuma well caught by Usman Khawaja at deep square leg for eight but the collapse Australia needed never materialised.
After Perth, the series continues in Hobart before concluding with a day-night test at Adelaide Oval.