Fast bowler Makhaya Ntini struck in his second over when he forced Upul Tharanga (0) to edge a rising ball to Herschelle Gibbs in the slips.
Ntini, however, suffered a hamstring injury after bowling the second ball of his sixth over. Dale Steyn completed the over, the last before lunch on Monday.
Sanath Jayasuriya was unbeaten on 13 at the break. Kumar Sangakkara was on 30 which included four boundaries in one over from Steyn.
Sangakkara was lucky to survive when he slashed Ntini to point where captain Ashwell Prince dived to get a hand to the ball but failed to take the catch.
South Africa are seeking a series-levelling win after being thrashed by an innings and 153 runs in the first Test at the Sinhalese sport club (SSC).
Sri Lanka's most successful chase so far has been 326-5 against Zimbabwe at the SSC during the 1997-1998 season.
Earlier, Muttiah Muralitharan equalled his own world record of four consecutive 10-wicket hauls as South Africa were bowled out for 311 in their second innings within the first hour.
The prolific off-spinner, who claimed five wickets in the first innings, finished with 7-97 in the second by taking all the three remaining wickets when the tourists resumed on 257-7.
Muralitharan had Nicky Boje caught behind for 15, trapped Steyn leg-before for zero and dismissed Mark Boucher to a catch at short-leg by Tillekeratne Dilshan.
Boucher made 65, adding 29 valuable runs for the last wicket with Ntini, who remained unbeaten on five.
Muralitharan's 12-225 here follows his match haul of 10-172 in the previous Test and 11-132 and 10-115 against England in Nottingham and Birmingham earlier in the year.
The 34-year-old's earlier feat of four successive 10-wicket hauls came at home during the 2001-2002 season when he took 11-196 against India, 10-111 against Bangladesh and 11-170 and 10-135 against the West Indies.
Muralitharan now has 657 wickets, second behind Australian record-holder Shane Warne's tally of 685, following his 18th 10-wicket success and 56th five-wickets-in-an innings haul.
He ended the short two-match series with 22 wickets.