A day after making a remarkable unbeaten 158, Dimuth Karunaratne again tormented South Africa with a half-century as Sri Lanka began to lock up the first Test after day two on Friday at Galle.
Karunaratne became only the fourth Sri Lankan to carry his bat through in the first innings, and his 60 second time around helped Sri Lanka to extend its lead to 272 runs.
South Africa faces a tall order to save the match on a crumbling pitch with plenty of assistance for spin bowlers.
Hashim Amla, who captained South Africa to a 1-0 series win the last time the Proteas were in Sri Lanka in 2014, said 272 was already a handy lead for the pitch.
"If we manage to restrict them to, I'd say 320, then certainly that would be a good target for us," Amla said. "If a couple of us have a good partnership and one of us plays like Karunaratne played, that would get us close to that score."
The visitors were bowled out for 126, their lowest total against Sri Lanka, eclipsing the 168 all out in Durban in 2011.
"Like most pitches, as the days go on the deterioration occurs," Amla said. "Today, it spun a little bit more than yesterday. Tomorrow, maybe in the morning session it might not spin as much and then break up and spin more and more."
Sri Lanka was 111-4 in its second innings. Left-arm orthodox spinner Keshav Maharaj picked up the first three wickets but, with a healthy first-innings lead of 161 runs, the hosts could play with freedom.
With five overs left to stumps, South Africa paceman Kagiso Rabada dismissed Karunaratne, who was caught at slip by Hashim Amla.
Danushka Gunathilaka (17) added 51 runs for the first wicket with Karunaratne and the former was dismissed when he gave Maharaj the charge but couldn't clear the boundary. Rabada ran to his left from long-on to complete the catch.
With the total on 64, Maharaj struck twice in the space of four deliveries, removing Dhananjaya de Silva (9) and Kusal Mendis (0) in quick succession. Mendis unsuccessfully reviewed after being given leg before wicket.
Maharaj, however, couldn't trouble Karunaratne as the left-hander was solid in defence and punished the loose balls with a couple of elegant drives. He was Sri Lanka's best batsman in 2017 having posted over 1000 runs in Tests. He missed Sri Lanka's recent tour of the Caribbean due to injury.
The Proteas had a dramatic collapse in the morning. Resuming from the overnight score of 4-1, the Proteas lost five wickets in the morning session for just 82 runs as the three-pronged spin attack of Rangana Herath, Dilruwan Perera and Lakshan Sandakan shared the bulk of the bowling.
Stand-in skipper Suranga Lakmal, the lone seamer in the Sri Lanka side, brought himself on in the last over before lunch and by then the spinners had sent down 37 overs.
From 51-6, South Africa recovered somewhat to reach 115-6 thanks to a seventh-wicket stand between Vernon Philander (18) and Francois du Plessis (49). Sri Lanka made the breakthrough after lunch as Philander was ruled leg before wicket to Dilruwan Perera, who finished with four wickets.
"What we have realized is that they don't play off-spin too well," said Perera, who took 16 wickets in the 2014 series. "That has been evident in their last few series they have played. Maybe that is one reason why I picked up four wickets today.
"We didn't expect to get them bowled out for 126, though."
Lakmal hastened South Africa's collapse with a superb piece of seam bowling accounting for the last three batsmen including captain Du Plessis, who was clean bowled by a delivery that cut back in sharply.
(With AP Inputs)