Johannesburg: A cultured Hashim Amla and controlled AB de Villiers established a priceless partnership to take South Africa's advantage to a considerable 199 over Australia on day three at the Wanderers Stadium on Saturday.
Fast bowler Pat Cummins struck twice as South Africa lost three wickets before lunch.
South Africa were 266 for three at the stump on day three, an overall lead of 199.
Cummins dismissed Jacques Rudolph for 24 and Jacques Kallis for two as the advantage swung to Australia, who need a win to level the series.
The 18-year-old debutant had figures of two for 46 from 17 overs.
South Africa also lost captain Graeme Smith, who made 36 before cutting off-spinner Nathan Lyon to backward point.
Starting the day 30 runs behind Australia's first innings total, South Africa quickly wiped out the deficit, with Rudolph looking in outstanding form as he made 24 off 23 balls with five fours.
But with the total on 40 Rudolph tried to pull a short ball from Cummins which rose sharply into his body and the ball looped off the splice of his bat to wicketkeeper Brad Haddin.
Smith was out tamely to Lyon and the scoring rate slowed as Hashim Amla and Jacques Kallis concentrated on defence.
But Cummins came back into the attack and produced a good delivery which Kallis edged to Australian captain Michael Clarke at first slip. He scored two off 19 balls.
Brief scores
South Africa 266 & 229 for 3 (Amla 89*, de Villiers 70*)
Australia 296
Status South Africa lead by 199 runs