Sri Lanka surged to 151-3 in their second innings on Saturday - a 365-run overall lead - as they sought a whitewash triumph over South Africa in their two-Test series.
After their spinners had skittled out South Africa for just 124 in their first innings, Sri Lankan openers Danushka Gunathilaka and Dimuth Karunaratne put on a quickfire 91 to set the foundation for another strong score on the Colombo pitch.
Gunathilaka was Sri Lanka's primary aggressor, hitting six fours and two sixes in his 61 off 68 balls after tea on the second day.
Keshav Maharaj struck twice to remove Gunathilaka and Dhananjaya da Silva, for a duck, but Karunaratne progressed smoothly at the other end to reach 59 while Angelo Mathews had 12.
The hosts built up their domineering lead at the end of a day in which their 10th-wicket pair added valuable runs to build a first innings of 338. South Africa were then routed by Sri Lanka's spinners with Akila Dananjaya taking 5-52.
Dananjaya and Rangana Herath frustrated South Africa through the morning session as they added 61 runs to the overnight total.
Left-arm spinner Keshav Maharaj eventually dismissed Herath to end the innings, and complete a haul of 9-129 - the second-best for a South Africa bowler and the best since the country made a post-apartheid return to Tests in 1991.
But Sri Lanka's 338 was always going to be a challenge and Dananjaya, Herath and Dilruwan Perera then tore through the South African batting, already exposed by their defeat in the first Test in Galle.
Dananjaya took his second five-wicket haul in Tests while Herath and Perera shared the remaining five South African wickets. Stand-in captain Suranga Lakmal was not required to deliver a single ball.
Only South Africa captain Faf du Plessis and wicketkeeper Quinton de Kock showed resistance, making 48 off 51 balls and 32 off 31 respectively.
South Africa lasted only 34.5 overs, after Sri Lanka had batted for 104.1 overs in their first innings.
Dananjaya, left out for the first Test at Galle, struck with his second ball of the match, having Dean Elgar caught at gully with a turning off-break.
He got Theunis de Bruyn edging behind in the next over, and Perera picked up the South Africa middle order to finish on 4-40.
The only batsman to put any pressure on Sri Lanka was Du Plessis, who attacked the spinners after lunch, sweeping with abandon as he struck eight fours and a six.
Du Plessis and Hashim Amla put on the best partnership of 55, but Perera dismissed them both within four overs of each other. Despite De Kock's aggressive innings, the remainder of South Africa's batting were easy meat when Dananjaya came back.
Du Plessis left the field at the end of the day with a worried look on his face.