Keshav Maharaj produced his career-best figures as he curtailed Sri Lanka's early momentum on day one of the second Test in Colombo with a magnificent eight-wicket display.

The touring Proteas suffered a 278-run defeat in the first Test of the two-match series and appeared set for a trying day in the field on Friday as Sri Lanka delivered their first century opening stand since October 2016.

But Maharaj dislodged openers Danushka Gunathilaka (57) and Dimuth Karunaratne (53) and then proceeded to rip through Sri Lanka's middle-order in posting figures of 8-116.

His stunning show restricted Sri Lanka to 277-9, with Dhananjaya de Silva (60) the only other home batsman to make a meaningful contribution.

After being skittled for 126 and 73 in the first Test, South Africa will now look to take the final wicket quickly on Saturday and back up Maharaj's efforts with a batting performance that puts them in a position to draw the series.

Sri Lanka's decision to bat first appeared to be vindicated as Gunathilaka and Karunaratne put on 116 runs inside 35 overs.

But Karunaratne was removed when he was strangled down the leg side by Maharaj to be caught by wicketkeeper Quinton de Kock. Two overs later, and with just one run added, Gunathilaka top-edged Maharaj to Kagiso Rabada, who tore forward from deep square leg to take a terrific catch.

De Silva shared stands of 36 with Kusal Mendis (21) and 54 with Roshen Silva (22) but he otherwise found little in the way of partners as the middle order failed to cope with Maharaj's accurate and aggressive approach.

Rabada, the day's other wicket-taker, dismissed Silva with a yorker before Niroshan Dickwella edged Maharaj to first slip, giving the left-armer his fifth five-wicket haul in the longest format.

De Silva's resistance was ended by a successful Sri Lanka review after Maharaj trapped him lbw and, with Akila Dananjaya and Rangana Herath the last men at the crease for the hosts, Sri Lanka will at least take solace in that there should be plenty for their own spinners to exploit.