Cape Town: Vernon Philander and Kagiso Rabada claimed four wickets each as South Africa ripped out Sri Lanka for 110 on the second day of the second test at Newlands on Tuesday.
South Africa did not enforce the follow-on and were 35 without loss at the close, 317 runs ahead and in a powerful position to claim the victory they need to clinch the series.
Sri Lanka collapsed after going to tea on 56 for two with Rabada making a decisive breakthrough at the start of the final session when he had Dimuth Karunaratne brilliantly caught at point by Temba Bavuma for 24.
A steady procession of wickets followed as captain Angelo Mathews and his deputy Dinesh Chandimal went cheaply after rash shots to Rabada's persistent pace barrage. The tall seamer had snared Kaushal Silva before tea and finished with figures of 4-37.
Spinner Keshav Maharaj added the valuable wicket of Dhananjaya de Silva lbw for 16 before Philander mopped up the tail.
Philander had Rangana Herath trapped in front and Suranga Lakmal caught in the slips by Hashim Amla after Dean Elgar parried the ball into the air. It was Philander's 150th test wicket.
Lahiru Kumara was bowled and Philander dismissed Nuwan Pradeep with the next ball so the fast bowler will start on a hat-trick when Sri Lanka bat again. Upul Tharanga finished unbeaten on 26.
Earlier, South Africa were all out before lunch with Quinton de Kock scoring 101 and teenager Kumara claiming six wickets for Sri Lanka in a career-best performance.
De Kock, 68 not out overnight, drove the first ball of the day for four and brought up his century off 122 balls, an instinctive innings full of quality shots.
Kumara, brought in to strengthen the Sri Lanka attack after their defeat in the first test, claimed a first five-wicket haul in tests and finished with figures of 6-122.
But it was a long spell in the field for Sri Lanka with South Africa's tail-enders adding 95 runs after resuming on 297 for six and the toil seemed to have some effect on the tourists' lethargic batting performance.
Stephen Cook (15 not out) and Dean Elgar (19 not out) will resume for South Africa on Wednesday with the home team bidding to wrap up the three-match series after victory in the first test in Port Elizabeth.
Brief scores
South Africa - 392 (Elgar 129, de Kock 101, Kumara 6-122) and 35 for 0
Sri Lanka - 110 (Philander 4-27, Rabada 4-37)
Status - South Africa lead by 317 runs