Colombo - Keshav Maharaj completed a South African record nine for 129 haul in the 2nd Test against Sri Lanka on Saturday before the home side hit back by taking quick wickets leaving South Africa in trouble on 19-3 at lunch.
Maharaj's nine wicket spree was South Africa's best in an innings since the country's post-apartheid return to Test cricket in 1991. But his form could not stop Sri Lanka's last wicket pair taking their side's first innings to a strong 338 on the second day in Colombo.
Akila Dananjaya and Rangana Herath added 61 runs to the overnight score to frustrate South Africa.
Returning to the bowling attack, Dananjaya then took the wickets of Dean Elgar and Theunis de Bruyn, before Herath removed Aiden Markram, as South Africa's top order crumbled again against spin.
The visitors could well have been four down, had Danushka Gunathilaka held on to a sharp chance from Hashim Amla, off the bowling of Herath, when Amla was on two.
Amla went to lunch at 7 not out, batting alongside captain Faf du Plessis, who had faced nine balls for his single run.
South Africa's reply seemed especially meek after Dananjaya and Herath's valiant last-wicket stand.
Their partnership was worth 74 overall, as they cut, edged, squirted and slashed their way through more than 23 overs together, denying not only Maharaj, but also fast bowlers Kagiso Rabada and Dale Steyn, who were unable to remove the batsmen with their bouncers.
Maharaj eventually took the wicket of Herath, who gloved a ball to a close fielder as he attempted to sweep. Herath finished with 35, while Dananjaya was 43 not out.
Maharaj's eventual figures were not only the second-best figures for a South Africa spinner ever -- just behind Hugh Tayfield's 9 for 113 against England in 1957 -- they are also the best figures in Asia for a visiting bowler.
Sri Lanka are without regular captain Dinesh Chandimal, who is suspended for the series over a ball tampering incident.