Sri Lanka's slow bowlers spun a web around South Africa who collapsed for a meagre 126 to concede a significant first innings lead on a spin-dominated second day of the opening Test on Friday.
Touring captain Faf du Plessis spent his 34th birthday trying to save his team's blushes but even his fighting 49, the only 20-plus score in the innings, could not stop South Africa from registering their lowest total in Sri Lanka.
Boosted by a first innings lead of 161, the hosts drove home the advantage to finish the day on 111 for four for an overall lead of 272 runs with six wickets in hand and a victory in sight.
Former captain Angelo Mathews, who was batting on 14 at stumps, and Roshen Silva on 10 will return on Saturday hoping to bat South Africa out of the contest in the first match of the two-Test series.
Resuming the day on four for one, the South African batsmen were all at sea against the turning ball and were reeling at 51 for six in the first session.
Du Plessis and Vernon Philander (18) arrested the slide and took South Africa past the 100-mark but then South Africa relapsed, losing their last four wickets for 11 runs.
Dilruwan Perera (4-46) led Sri Lanka's three-pronged spin attack with aplomb, while stand-in skipper Suranga Lakmal (3-21) also turned in a strong performance.
Spin reigned supreme in the final session as well with left-arm spinner Keshav Maharaj claiming 3-37 even though Sri Lanka kept on stretching their lead.
Opener Dimuth Karunaratne continued to have a fruitful match, following his first innings 158 with a fluent 60.
Sri Lanka 1st innings: 287 all out in 78.4 ovs (D Karunaratne 158, K Rabada 4-50, T Shamsi 3-91).
South Africa 1st innings: 126 all out in 54.3 ovs (Faf du Plessis 49, D Perera 4-46, S Lakmal 3-21).
Sri Lanka 2nd innings: 111 for four in 37 ovs (D Karunaratne 60, K Maharaj 3-27).