Sri Lanka trail South Africa by 351 runs after they reached 104-3 at lunch on day three of the first Test match in Galle.
After starting the day on 30-0, the hosts soon lost their first wicket when Kaushal Silva was removed by Dale Steyn without adding to his overnight score of eight.
However, Kumar Sangakkara put on 59 runs for the second wicket with Upul Tharanga, who had eased to 65 with 12 fours, but the wicketkeeper fell for 24 to give South Africa plenty of encouragement before the interval.
It appeared as though Sri Lanka would make lunch without the loss of further wickets, but with the final ball of the session, Steyn trapped Mahela Jayawardene in front of his stumps to give South Africa the advantage.