Sri Lankan spinners led by Dilruwan Perera wreaked havoc to put South Africa in deep trouble at 86 for six on day two of the first Test in Galle on Friday.
Perera claimed three wickets including Hashim Amla for 15 with his wily off-spin to rattle South Africa's top and middle order after the visitors started the day on 4-1 in response to the hosts' 287.
Skipper Faf du Plessis, on 22, and Vernon Philander, on 16, were batting when lunch was taken with the visitors still trailing by 201 runs in the first innings.
Veteran left-arm spinner Rangana Herath, who got Aiden Markram for nought on Thursday, removed nightwatchman Keshav Maharaj for three in the third over of the day to set the tone for the hosts' domination in the morning session.
Perera soon sent Dean Elgar packing on eight and struck twice again to reduce the visitors to 51-6.
Du Plessis and Philander then put together an unbeaten 35-run stand as Sri Lanka continued to put pressure with spin from either end.
Left-arm wrist spinner Lakshan Sandakan also made an impact after getting Temba Bavuma bowled for 17.
Stand-in-captain Suranga Lakmal is the only regular paceman in the Sri Lankan XI as he bowled an over before lunch on a seemingly turning sub-continent pitch.
Earlier, opener Dimuth Karunaratne gave Sri Lanka a fighting total on the opening day with his unbeaten 158 after the hosts elected to bat first at the start of the two-match series.