Perth: South Africa's bowlers rallied magnificently after the loss of pace spearhead Dale Steyn before their batsmen pushed to an 102-run lead at the close on day two of the first test against Australia on Friday.
Steyn left the field with a shoulder injury before lunch and was later ruled out of the series with a stress fracture in a hammer blow for the touring side.
But the remaining Proteas bowlers ripped out the hosts for 244 before tea before Dean Elgar (46 not out) and JP Duminy (36 not out) combined for an unbroken 59-run stand to steady the innings after two early wickets in the final session.
South Africa were 104 for two at stumps having fought back strongly after Australia had dominated the first day.
Vernon Philander took 4-56, teaming up brilliantly with debutant left-arm spinner Keshav Maharaj (3-56) as Australia lost 10 wickets for 84 runs after resuming in the morning at 105 without loss.
"A few of us probably have to look at ourselves in the mirror and say why did we play those shots?," opening batsman David Warner said of a collapse that included four ducks.
Rising pace talent Kagiso Rabada took three wickets, with Steyn grabbing the first of the day to deny Warner a century.
The Australian vice captain and opener Shaun Marsh pushed Australia to 158 before Steyn had Warner caught in the slips for 97.
Steyn exited in his following over but it did little to break the Proteas' focus, with Rabada bowling Usman Khawaja for four and Maharaj grabbing a memorable first wicket, trapping Steven Smith lbw for a duck as the captain skipped down the wicket.
Marsh was given out lbw in the final over before lunch and the rot continued after the break.
Bowling a tight line and length, Philander and Maharaj ratcheted up the pressure with three straight maidens before Mitchell Marsh succumbed for an eight-ball duck.
Adam Voges showed some resistance but Rabada caught a leading edge off his own bowling to dismiss him for 27.
Mitchell Starc lasted only six balls before holing out for a duck off Maharaj, driving to South Africa captain Faf du Plessis at midwicket.
Wicketkeeper Peter Nevill managed 23 before Josh Hazlewood (4) and Nathan Lyon, the fourth duck of the innings, fell quickly to wrap up the Australian innings.
Shaun Marsh took a sharp catch at midwicket to dismiss Stephen Cook for 12 off paceman Peter Siddle and Josh Hazlewood bowled Hashim Amla for one, having dismissed him for a duck in the first innings.
But Elgar and Duminy stood firm in the last hour to complete a fine day for South Africa and give the tourists hope of setting a big target on day three.
South Africa 1st innings: 242 (Q. de Kock 84, T. Bavuma 51; M. Starc 4-71)
Australia 1st innings:
D. Warner c Amla b Steyn 97
S. Marsh lbw b Philander 63
U. Khawaja b Rabada 4
S. Smith lbw b Maharaj 0
A. Voges c & b Rabada 27
M. Marsh lbw b Philander 0
P. Nevill c Amla b Maharaj 23
M. Starc c du Plessis b Maharaj 0
P. Siddle not out 18
J. Hazlewood c Duminy b Philander 4
N. Lyon c Elgar b Philander 0
Extras (lb-3, nb-5) 8
Total (all out, 70.2 overs) 244
Fall of wickets: 1-158, 2-167, 3-168, 4-181, 5-181, 6-202, 7-203, 8-232, 9-243, 10-244
Bowling: D. Steyn 12.4-3-51-1, V. Philander 19.2-2-56-4 (nb-3), K. Rabada 20-1-78-2 (nb-2), K. Maharaj 18.2-5-56-3
South Africa 2nd innings:
S. Cook c S. Marsh b Siddle 12
D. Elgar not out 46
H. Amla b Hazlewood 1
J. Duminy not out 34
Extras (lb-5, nb-1, w-5) 11
Total (for 2 wickets, 40 overs) 104
Fall of wickets: 1-35, 2-45
To bat: F. du Plessis, T. Bavuma, Q. de Kock, V. Philander, D. Steyn, K. Rabada, K. Maharaj
Bowling: M. Starc 9-4-18-0, J. Hazlewood 10-2-31-1 (nb-1), P. Siddle 8-4-12-1, M. Marsh 4-1-11-0 (w-1), N. Lyon 9-2-27-0
Umpires: A. Dar & N. Llong
TV umpire: Richard Kettleborough
Match referee: Andy Pycroft