Australia were 86 for three in their second innings at tea, still 53 runs behind South Africa's first innings total of 382.
De Villiers made a magnificent 126 not out and had good support from the tail as South Africa took a first innings lead of 139, scoring freely before they were all out for 382 shortly before the scheduled lunch break.
Fast bowler Kagiso Rabada, under threat of a suspension which could rule him out of the rest of the four-Test series, made a key breakthrough for South Africa when he bowled David Warner for 13 during a hostile opening spell in which his fastest delivery was timed at 151 kmh.
It was the third time in four innings that Smith, the number one Test batsman in the world, had fallen to left-arm spin - twice to Maharaj and once to part-timer Dean Elgar.
Vernon Philander (36) and Maharaj (30) helped De Villiers add 84 for the eighth wicket and 58 for the ninth wicket as South Africa dominated a sunny morning.
Australia's fast bowlers, who had a heavy workload on the previous day, wilted under an assault in which De Villiers played strokes that were sometimes breathtaking.
He hit 20 fours and a six in a 146-ball innings. It was his 22nd Test century and his sixth against Australia.
Philander played a solid innings, while Maharaj slammed two sixes and three fours off 24 balls.
South Africa added 119 runs off 23.4 overs before a direct hit from Smith in the covers ran out last man Ngidi at the bowler's end as the batsmen tried a risky second run to keep De Villiers on strike.
(This story has not been edited by Business Standard staff and is auto-generated from a syndicated feed.)