The Australians were dismissed for 383 at tea, with the last four wickets adding 100 runs to put the home side in command.
Khawaja's 308-ball vigil finally came to an end 30 minutes into the third day when he was trapped leg before wicket by Vernon Philander.
The unflappable left-hander occupied the crease for 466 minutes after he was forced to hurriedly open the innings after a miscalculation over David Warner's time off the field for injury treatment when the Proteas declared.
Khawaja left the field to a standing ovation from the Adelaide Oval crowd following his second-highest Test score, amassed over three days, ranking only below his 174 against New Zealand in Brisbane last year.
It was the Pakistan-born batsman's fifth Test century, all scored over the last 12 months.
Mitchell Starc clubbed his seventh Test half-century with a 91-ball 53 before he was caught and bowled by Kagiso Rabada, ending a crowd-pleasing knock that featured five fours and a six.
Nathan Lyon chipped in with 13 with Josh Hazlewood remaining 11 not out.
Kyle Abbott was the best of South Africa's bowlers with an economical three wickets for 49 off 29 overs with young gun speedster Rabada claiming three for 84.
Australia are trying to prevent the Proteas from an unprecedented series clean sweep after huge defeats in the opening two Tests.
(This story has not been edited by Business Standard staff and is auto-generated from a syndicated feed.)