South Africa lost opener Aiden Markram late on day one as Sri Lanka hit back in the opening Test in Galle on Thursday.
Veteran spinner Rangana Herath snared Markram out for nought to strike a big blow for the hosts before stumps, leaving the Proteas 1-4. Dean Elgar, on four, and nightwatchman Keshav Maharaj were at the crease at the close of play on a rain-hit day.
Earlier, Sri Lanka opener Dimuth Karunaratne remained unbeaten on 158 as the hosts were bowled out for 287.
Karunaratne built crucial partnerships including a 63-run 10th wicket stand with Lakshan Sandakan, who made 25, after the hosts elected to bat first at the start of the two-match series.
Paceman Kagiso Rabada claimed four wickets while left-arm wrist spinner Tabraiz Shamsi got three to wrap up Sri Lanka's innings in an extended final session after rain interrupted play in the afternoon.
Rabada, who finished with figures of 4-50 from his 14 overs, tore through the Sri Lankan middle-order after lunch as the islanders slipped from 2-115 to 5-119.
The hosts had elected to bat first at the start of the two-match series.
Left-arm wrist spinner Tabraiz Shamsi made an impact in just his second Test with two crucial wickets to hurt Sri Lanka, who had taken lunch at 2-93.
Shamsi added to his morning's wicket tally, having Niroshan Dickwella caught at slip for 18, just before rain interrupted play.
He had earlier bowled Dhananjaya de Silva before lunch on a surface that was already offering significant turn.
Karunaratne, who completed his 15th Test half-century early in the afternoon session, has kept alive Sri Lanka's hopes of posting a respectable total.
Although he had his edge repeatedly beaten by Shamsi, Karunaratne survived Rabada's fearsome spell.
Veteran quick Dale Steyn had set Sri Lanka's post-lunch slump in motion, having Kusal Mendis caught at mid-on for 24. That wicket moved him within one of matching Shaun Pollock’s mark for most Test scalps by a South African.
Sri Lanka: Suranga Lakmal (capt), Dimuth Karunaratne, Danushka Gunathilaka, Dhananjaya de Silva, Kusal Mendis, Angelo Mathews, Roshen Silva, Niroshan Dickwella (wk), Dilruwan Perera, Rangana Herath, Lakshan Sandakan
South Africa: Faf du PLessis (capt), Dean Elgar, Aiden Markram, Hashim Amla, Temba Bavuma, Quinton de Kock (wk), Vernon Philander, Keshav Maharaj, Tabraiz Shamsi, Kagiso Rabada, Dale Steyn