Sunday began with de Villiers making a 22nd test century with his 126 not out taking South Africa to 382 all out for the big lead.
Rabada took two more wickets, including a crucial late breakthrough to get Usman Khawaja out for 75 seven minutes before the end of the day.
Rabada followed up South Africa's success with the bat to take 3-38 and improve his match haul to eight wickets.
De Villiers did not play Test cricket between January 2016 and December 2017, after he decided he needed time away from the game.
It was de Villiers' first Test hundred since 2015, a long period that makes better sense when the break that he took from the global game between January 2016 and December 2017 is taken into account.
"I was very motivated to prove that I can still play this game", said De Villiers, whose performance was described by his former captain Graeme Smith as "one of the great Test innings".
Rabada had earlier dismissed David Warner (13) - although he risks further sanction after a send-off that saw him scream in the batsman's face - and Shaun Marsh (1), while fellow seamer Lungi Ngidi removed Cameron Bancroft, the opener bowled for 24 via an unfortunate deflection off his left boot.
Australia lead 1-0 in the four-test series.
Rabada's eighth wicket of the match kept the Proteas on track to level the spiteful four-test series, with Marsh to resume on 39 knowing he and Tim Paine must do the bulk of the work if the tourists are to scrape together a decent target.
"I won't say we're frustrated (with him)", he said.
Offspinner Nathan Lyon also made his presence felt with the wicket of de Kock for 9.
Even though Elgar and Amla put on 88 for South Africa for the third wicket, that stand took almost 3 1/2 hours and 278 balls.
Rabada bowled Warner with a lovely delivery on day three then stormed over to the vanquished vice-captain and screamed in his face.
Match referee Jeff Crowe heard Rabada's side of events, with the express paceman understood to have argued that contact with Smith's shoulder was not deliberate. "He's crossed the line a few times and I think he's regretting that", said De Villiers.
"I still feel our bowlers have a lot in them and they are going to come with a lot of fire on Monday morning and hopefully knock them over". He reached 100 off just 117 balls, a free-flowing innings that made batting look much easier than it really was, especially with the ball reverse swinging on Day 2. I was quite nervous, I haven't been in this position for a while and it means the world to me. "I don't think it showed but I was telling Vern out there that I was struggling to breathe and my legs literally went numb", he said.