De Silva made 43 not out as Sri Lanka struggled to 181 for seven - still 105 runs behind South Africa's first innings total of 286 - before bad light ended play.
South African new ball bowlers Vernon Philander and Kyle Abbott put the Sri Lankan batsmen under pressure in seam-friendly conditions, with the first three wickets falling for 22 runs.
It looked as though a full-scale collapse was possible but Sri Lankan captain Angelo Mathews made a solid 39 before De Silva came out to bat at number seven and played an impressive innings, with assistance from Dinesh Chandimal and Rangana Herath.
Rabada struggled to find his rhythm and conceded 63 runs in 13 overs, although he did take the key wicket of Mathews, caught low down at third slip by Dean Elgar.
More From This Section
De Silva, playing in only his sixth Test, showed some of the quality that has already brought him centuries against Australia and Zimbabwe, although he survived a caught and bowled chance to left-arm spinner Keshav Maharaj when he was on 27. When play ended he had faced 69 balls and hit five fours.
The previous Test best for Lakmal, 29, was four for 78 against Pakistan in Dubai in January 2014.
Philander was caught at deep square leg when he top-edged a pull against Nuwan Pradeep in the fifth over of the morning after South Africa had resumed at 267 for six.
Maharaj edged an away swinger to wicketkeeper Dinesh Chandimal to give Lakmal his fifth wicket and Abbott was run out after a mix-up with Quinton de Kock.
But the hosts hit back almost immediately as Philander and Abbott ripped into their batting. Both gained appreciable movement through the air and off the pitch as three wickets fell in the first eight overs before captain Mathews joined a patient Kaushal Silva to add 39 runs for the fourth wicket.
Silva was the only one of the top four in the Sri Lankan batting order to show a solid defensive technique in tricky conditions. But he made only 16 off 108 balls before he was leg before wicket to Philander, who produced a ball that cut back after a succession of deliveries that left the batsman.