Spinners led by Dilruwan Perera put hosts Sri Lanka in firm command of the first Test on Friday after South Africa were bowled out for 126 -- their lowest Test innings in the country.
First innings centurion Dimuth Karunaratne then made a fluent 60 as the hosts ended day two on 111 for four, leading by 272 runs at the Galle International Stadium.
Angelo Mathews, on 14, and Roshen Silva, on 10, were batting at the close of play after left-arm spinner Keshav Maharaj claimed three wickets for South Africa.
But it was the Sri Lankan bowlers who starred on a dramatic day that witnessed South Africa slip to 51 for six before being bowled out in the second session of play.
The dismal effort set a new low for South Africa in Sri Lanka, worse than their 169 in Colombo in 2006.
"We wanted to take a lead. We stopped easy runs, put pressure and got the wickets early and things went on pretty well I thought," Perera told reporters.
"We didn't expect to get them bowled out for 126 though," he added.
Perera returned impressive figures of 4/46 with his off-spin, while paceman and stand-in skipper Suranga Lakmal took three wickets.
Veteran spinner Rangana Herath started Sri Lanka's dominance by sending back nightwatchman Maharaj early, and Perera soon took crucial wickets including the dangerous Hashim Amla for 15.
Skipper Faf du Plessis made a gritty 49 and his 64-run seventh-wicket partnership with Vernon Philander, who made 18, was the best that South Africa could muster in their 54.3 overs.
Herath grabbed two wickets while left-arm wrist spinner Lakshan Sandakan claimed one -- the three spinners sharing seven wickets in total.
"We were trying not to let a batsman settle. Keep changing angles and Herath even changed ends. If the wicket is turning, I tend to change those angles," said Perera.