Galle, Sri Lanka: Left-hander Lahiru Thirimanne and captain Angelo Mathews were trying to extricate Sri Lanka from trouble as the home side reached 182-4 at tea on the third day Friday of the first test in reply to South Africa's 455-9 declared.
Thirimanne was on 32 and Mathews on 24 as the Sri Lanka middle order struggled to capitalize on opener Upul Tharanga's innings of 83.
Tharanga, 20 in an overnight score of 30 without loss, marked his return to test cricket after more than six years with his fourth half century
The left-hander struck one six and 14 fours before he was stumped off spinner Jean-Paul Duminy. His was the only wicket to fall in the middle session.
Earlier, pace bowlers Dale Steyn and Morne Morkel shared three wickets in the morning session to peg back the home side.
Tharanga batted with confidence well past lunch, adding 59 runs for the second wicket with Kumar Sangakkara, who was out for 24.
Tharanga passed 50 with two fours off an over from Duminy. He struck the offspinner past point and two deliveries later, straight down the ground, to move from 45 to 53.
But South Africa made early inroads through the dismissal of Kaushal Silva and the experienced pair of Sangakkara and Mahela Jayawardene in the first session.
Silva was caught by Vernon Philander at the long-leg boundary without adding to his overnight score of 8 as he tried to hook Steyn.
Sangakkara was out immediately after a brief 10-minute rain break as he shaped for a pull off Morkel but played the ball on to the stumps.
Jayawardene, who has announced he will retire from tests next month, was trapped lbw by Steyn after making just 3.