Rabada took two more wickets, including a crucial late breakthrough to get Usman Khawaja out for 75 seven minutes before stumps.
Nightwatchman Kagiso Rabada was the only wicket to fall in the opening 54.3 overs of the day, with Elgar and Amla digging in as the tourists started to reverse-swing the old ball.
De Villiers took nearly two years out of the Test arena to concentrate on the shorter formats of the game and spend more time with his young family but came back in December.
Nobody seems to want this series as much as de Villiers, who took most of 2017 off from the Test game to recharge his batteries for contests against India and Australia.
De Villiers made a magnificent 126 not out and had good support from the tail as South Africa scored freely before it was all out for 382 shortly before the scheduled lunch break.
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. He was the anchor in late partnerships of 44 with Quinton de Kock, 84 with Vernon Philander (36) and 58 off just 43 balls with Keshav Maharaj (30).
John Cena in action, HUGE WrestleMania matches to be decided
Any match between these two teams will be intense and can see anything happen - especially with the Tag Team titles on the line. Check out all of the remaining matches, results and clips of the show below. 'What do you think, man?' and he was okay with it.
Rabada's is the fourth player disciplinary case of the series so far after Australia's Lyon and Warner and South Africa's de Kock were all found guilty of bringing the game into disrepute in the first test in Durban, where Australia won by 118 runs.
"I won't say we're frustrated (with him)", he said.
The incident happened after Rabada scalped Smith's crucial wicket for 25 and celebrated the victory by brushing his shoulder against the departing skipper.
Rabada, recently ranked the No. 1 bowler in test cricket, has also previously been disciplined three times for his actions after dismissing batsmen and served a one-test ban in England previous year.
Don't get me wrong, there is a tinge of poor form from the South African fans makingmasks of SBW to taunt Warner, but it would be little different to how Australian fans welcome visiting teams.
While South Africa's best young bowler was both good and bad, its best batsman was sublime.
The Proteas will resume at 7-263 on Sunday morning in Port Elizabeth, with de Villiers unbeaten on 74. "I was very nervous in the nineties". I don't think it showed but I was telling Vern (Philander) out there 'I'm struggling to breathe here.' My legs literally went numb.