Khawaja remained unbeaten on 138 at stumps with Mitchell Starc batting on 16 at the other end. The hosts now lead the Proteas by 48 runs. The visitors had declared their first innings at 259/9.
Khawaja, who has faced 285 balls so far, hit 12 boundaries during his daylong vigil in the middle. This was his fifth Test century.
Australia captain Steven Smith and debutant wicketkeeper-batsman Peter Handscomb notched up half-centuries.
Smith scored 59 with eight boundaries and a six before being run out following miscommunication with Khawaja.
Handscomb scored at a fast clip, notching up 54 runs off 78 deliveries. He hit six boundaries before an incoming Kyle Abbott delivery went between his bat and pad to disturb the off-stump.
Abbott was the most successful among the South African bowlers with figures of 3/38. Vernon Philander and Kagiso Rabada produced excellent displays of fast bowling to pick up a wicket each.
Abbott got rid of David Warner as well which saw Smith join Khawaja in the middle. The duo set about trying to pull the Australians out of trouble with a 137-run stand.
Both batsmen seemed to be in good touch and could have put Australia in a more dominant position, but Smith had to go back to the pavilion due to some poor running between the wickets between him and Khawaja.
Smith had called for a quick single off Tabraiz Shamsi, but had to get back to his crease with Khawaja belatedly deciding that a run wasn't feasible. However, before Smith got back to safety, Vernon Philander's throw found South Africa wicketkeeper Quinton de Kock who whipped off the bails.
Handscomb then joined Khawaja in the middle and the duo added 99 runs between them to take Australia past the Proteas' first innings total.
The South African pacers however, hit back late in the final session of the day with three quick wickets.
Handscomb batted steadily although he had to wait nervously towards the end of the post-lunch session when South Africa unsuccessfully reviewed a leg before call. He soon raced past the half-century mark with three consecutive boundaries off Philander.
But he did not last long after reaching the landmark and was bowled by an in-swinger from Abbott two overs later.
It brought another debutant Nic Maddinson to the middle, but unlike Handscomb, Maddinson couldn't make use of the opportunity and was bowled by a Rabada yorker before he could open his account.
Matthew Wade did not last long as well, attempting to play at an outgoing delivery from Philander but only managed an outside edge to de Kock.
(This story has not been edited by Business Standard staff and is auto-generated from a syndicated feed.)