Sri Lanka opening batsman Dimuth Karunaratne struck a defiant unbeaten hundred on his return to the side to give the hosts a fighting first innings total in the opening Test against South Africa.
The 30-year-old carried his bat through the Sri Lankan innings to remain unbeaten on 158 as the hosts finished on 287 after stand-in captain Suranga Lakmal won the toss and chose to bat in the first of the two-Test series.
South Africa lost opener Aiden Markram to veteran left-arm spinner Rangana Herath to reach four for one at stumps. Dean Elgar and nightwatchman Keshav Maharaj were at the crease.
The hosts' regular captain Dinesh Chandimal has pleaded guilty to a disciplinary breach during the side's second Test against West Indies last month and has opted to sit out of the series against South Africa.
The International Cricket Council, the world governing body of the sport, is due to announce a verdict in the case soon.
On a turning surface at Galle, it was fast bowler Kagiso Rabada who did the maximum damage for the touring side with four wickets for 50.
Left-arm wristspinner Tabraiz Shamsi, playing only his second Test, returned figures of 3-91.
Former pace spearhead Dale Steyn, returning to the South African team from injury having last played a Test in January, picked up the wicket of Kusal Mendis for 24 to trigger a mini collapse.
Rabada removed former captain Angelo Mathews and Roshen Silva in the same over as the hosts lost three wickets for four runs to be left reeling at 119-5.
Experienced Karunaratne, back to open the batting for the hosts after missing the West Indies tour due to injury, stitched together meaningful stands with Niroshan Dickwella, who made 18, and Lakshan Sandakan, the duo adding 63 for the last wicket.
The left-handed batsman hit 13 fours and one six during his 222-ball unbeaten knock.