Australia were eventually all out holding just a two-run lead on the first innings.
Openers David Warner and Shaun Marsh had taken the score to 158-0.
Warner had bashed his way to 97 off 100 balls with 16 fours and a six before, just after the first drinks break, he chased a wide delivery from paceman Dale Steyn to send an edge to Hashim Amla at first slip.
Unfortunately for the Proteas Steyn left the field soon after clutching his right shoulder in what looked like a recurrence of an old injury.
Marsh brought up his fifth test fifty off 110 balls but Usman Khawaja (4) did not last long before being bowled by a superb full, in-swinging delivery from fast bowler Kagiso Rabada.
Steve Smith (0) became Keshav Maharaj’s first test wicket when he was given out leg-before. Smith had come a long way down the pitch and asked for a review but replays showed that the ball would have just clipped leg stump and the decision stayed with the on-field umpire.