Lakmal took four for 62 in 23 overs as South Africa reached 267 for six at the end of a day on which they failed to capitalise on a century opening partnership between Stephen Cook and Dean Elgar.
Opening bowler Lakmal pegged back the hosts by taking the first three wickets and later dismissed South African captain Faf du Plessis. Left-arm spinner Rangana Herath took two wickets, including that of JP Duminy, South Africa's top scorer with a fluent 63.
When Du Plessis won the toss and decided to bat on a well-grassed but slow pitch, it was anticipated that the first two hours would be the most difficult for batsmen, with early life before moisture in the surface dried out.
Cook (59) and Elgar (45) were seldom troubled as they reached 92 for no wicket at lunch. They started cautiously and left the ball well before gradually lifting the tempo.
Any thoughts of a South Africa run feast in the afternoon were spoiled by Lakmal in a superb spell immediately after lunch. He was backed up well by Angelo Mathews and Nuwan Pradeep as only 13 runs were added in 10.2 overs for the loss of both openers.
Cook was stuck on the crease as he edged a ball from Lakmal that seamed away from him, with wicketkeeper Dinesh Chandimal taking a good, low catch to end an opening stand of 104.
Only one run was added off the next 29 balls before the left-handed Elgar pushed at a ball angled across him to present a second catch to Chandimal.
Duminy threatened to swing the balance back to South Africa. The left-hander hit the first ball he faced from Lakmal through the covers for four and raced to 34 off the first 23 balls he faced, including eight fours.
By contrast, Hashim Amla, who came in at number three, struggled to find his timing, scoring only 20 runs off 76 balls before Lakmal returned to the attack immediately after tea and had him caught behind.
It was a continuation of a poor run of form by Amla, who scored only 98 runs at an average of 16.60 during South Africa's series victory in Australia last month.
The dismissal meant that Amla's Test career average dipped below 50 for the first time in more than four years.
Duminy, meanwhile, was unable to bat with his earlier fluency as the Sri Lankans altered their line to prevent his flow of off-side drives. He eventually lost patience and missed a sweep against Herath to be given out leg before wicket.
He sought a review but umpire Bruce Oxenford's decision was shown to be correct. Duminy made 63 off 95 balls with ten fours.
The Sri Lankans, though, successfully reviewed a decision by Oxenford four overs later when Temba Bavuma went back to Herath and was originally given not out when he was struck on the pads.
Lakmal's fourth strike came in the fourth over with the second new ball when he made the ball move sharply off the pitch to have Du Plessis caught at second slip for 37.