South Africa batted cautiously to reach 98 for three as they try to preserve their 1-0 lead in the series in the second Test and final against Sri Lanka on Friday.
The touring side, replying to the hosts' 421 all out, trailed by 323 runs at the close on the second day with Hashim Amla unbeaten on 46 and AB de Villiers on 11.
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 wicketkeeper 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 (2) and Lakmal (4) to catches by wicketkeeper Quinton de Kock.
Debutant Dickwella's innings of 72 off 116 deliveries ended in a run out when he hesitated over a single to a ball that went off Herath's shoulder and De Kock reacted quickly to throw the stumps down.
Leg-spinner Imran Tahir picked up his first wicket after conceding over 100 runs when he had Perera caught by Amla at mid-on for 12 attempting a big hit.
Jayawardene was run out for 165 and Dickwella scored a half-century as Sri Lanka piled on the runs on the second morning.
The hosts were 395 for six at lunch with wicketkeeper Dickwella unbeaten on 63 and Perera on nine.
South Africa's only success of the morning was the wicket of Jayawardene, who had passed 150 for the 16th time in his career before he was run out.
The elegant right-hander swept JP Duminy to fine leg and Petersen's direct throw at the stumps caught the diving batsman well short of his ground.
His 165 came off 284 balls and included one six and 17 fours.
Image: Hashim Amla
Photograph: Dinuka Liyanawatte/Reuters