South Africa batted cautiously to reach 98 for three at close on day two as they try to preserve their 1-0 lead in the series in the second and final Test against Sri Lanka.
The tourists, replying to Sri Lanka's 421 all out, trailed by 323 runs at stumps with Hashim Amla unbeaten on 46 and AB de Villiers on 11.
Sri Lanka first innings 421
South Africa first innings
A Petersen c and b Herath 2
D Elgar c Kaushal b Perera 1
F du Plessis c Dickwella b Lakmal 36
H Amla not out 46
AB de Villiers not out 11
Extras: (1lb, 1nb) 2
Total: (for 3 wickets) 98
Fall of wickets: 1-3, 2-13, 3-71
Amla had two escapes on 10 and 34, edging a drive off Dilruwan Perera past Mahela Jayawardene's outstretched hand at slip and then having his stumps shattered by Suranga Lakmal as he moved away from his crease when a crow flew across the pitch.
The bowler appealed to the umpire who signalled a dead ball.
Sri Lanka's only success in the final session was the wicket of Faf du Plessis who was caught brilliantly down the leg side by wicket-keeper Niroshan Dickwella off Lakmal for 36 to end a partnership of 58 with Amla.
Sri Lanka's spinners had taken two early wickets to reduce South Africa to 23 for two at tea.
Left-armer Rangana Herath, who opened the bowling, struck with his fifth ball when he forced Alviro Petersen to hit back a tame return catch with his score on two.
Perera, who replaced fast bowler Lakmal after only four overs, had Dean Elgar, on one, caught off the inside edge off his third ball by Kaushal Silva at short leg to leave South Africa in trouble on a turning pitch at 13 for two.
Sri Lanka's first innings ended an hour after lunch with Vernon Philander picking up the last two wickets of Ajantha Mendis (two) and Lakmal (four) to catches by wicketkeeper Quinton de Kock.