Wiaan Mulder picked up his maiden Test wicket as Sri Lanka crumbled in the first session on Day 2.
Sri Lanka were bowled out for 154, conceding a 68-run lead to South Africa.
Aiden Markram fell early in the innings leaving the rebuilding job to Amla and du Plessis to extend South Africa's lead.
After Amla couldn't convert is start and make the most of a dropped chance, Quinton de Kock, who scored 86 in the first innings, fell cheaply before Tea as momentum swung in Sri Lanka's favour.
Faf du Plessis kept South Africa afloat, but the hosts lost 7 for 38 in the second innings to set Sri Lanka a target of 197.
Sri Lanka ended the day, having lost two wickets, but with 137 runs needed to win.