Perth: JP Duminy and Dean Elgar scores patient centuries and share 250-run stand on the third day at the WACA, Perth on Saturday
At stump on the third day the visitors were six for 390 in their second innings, an overall lead of 388.
Elgar was caught by Starc on Hazlewood on 127, and Duminy fell to the last ball before tea for 141, the pair adding 250 for the third wicket after the Proteas lost two early second innings wickets late on the second day.
Duminy chased a wide ball from Peter Siddle (2-47) and got a fine edge, being given out on a decision review after umpire Aleem Dar had turned down the Australian appeal.
The left-hander had faced 225 balls, hitting 20 fours and one six.
Both batsmen made their Test debuts at the WACA Ground and the pair each notched their fifth Test centuries between lunch and tea.
For Elgar, it would have been particularly sweet as he was dismissed for a pair on debut in 2012.
He had hits 17 fours and one six, reaching triple figures with a lovely cover drive from the bowling of Nathan Lyon.
Duminy and Elgar had few problems with an Australian attack which appeared to wilt in the heat, with first innings destroyer Mitchell Starc struggling with his control and looking little like the player who claimed four wickets on the opening day.
Starc, in his first Test since a nasty leg injury and coming off a limited preparation, bowled a host of wayward deliveries and grew increasingly frustrated as the day wore on.
His woes were compounded when he misjudged a high ball at mid-on when Elgar was 81 and failed to get a hand to the difficult chance.
The South Africans will be one bowler down in the Australian second innings, with champion quick Dale Steyn expected to be out for at least six months due to a shoulder problem which is likely to require surgery.
However, they will also be encouraged by some inconsistent bounces on the third day as the pitch started to deteriorate.
After winning the toss and being dismissed for 242, the South Africans appeared certain to be facing a massive first innings deficit when Australia cruised to 158 for none before lunch on day two, but the home side then collapsed in stunning fashion to make just 244.
South Africa - 242 (De Kock 84, Starc 4-71, Hazlewood 3-70) and 6/390 (Duminy 141, Elgar 127)
Australia - 244 (Warner 97, S Marsh 63, Philander 4-56, Maharaj 3-56)
Status - South Africa lead by 388 runs