South Africa's batting struggles on its tour of Sri Lanka continued as it slumped to 19 for three at lunch on day two of the second cricket test at the Sinhalese Sports Club grounds in Colombo on Saturday.

At the break, South Africa trailed Sri Lanka by 319 runs on the first innings, with seven wickets in hand.

Sri Lanka attacked the Proteas with spin from the new ball and claimed early results. Off-spinner Akila Dananjaya dismissed Dean Elgar and Theunis de Bruyn in successive overs, before veteran left-arm orthodox spinner Rangana Herath trapped Aiden Markram leg before wicket for seven, reducing the tourists to 15 for three.

Herath could have dismissed the experienced Hashim Amla as well when he was on two, but Danushka Gunathilaka put down a straight forward chance at short extra-cover. Amla took a single off the drop catch to bring up 9000 test runs, becoming the third South African to the landmark after Jacques Kallis and Graeme Smith.

As play resumed on day two, Sri Lanka's last wicket pair of Akila Dananjaya and Herath frustrated the Proteas by extending their stand to 73 runs in 140 deliveries, a new record for the tenth wicket in tests between these two countries.

Keshav Maharaj finally dismissed last man Herath for 35 to finish with nine for 129 runs, the best bowling figures for South Africa since its test readmission in 1992. His effort is the second best all-time test analysis by a South African, behind Hugh Tayfield's nine for 113 against England in Johannesburg more than 60 years ago.

Dananjaya was left stranded on 43 not out, his career best score.

Sri Lanka lead the two-match series 1-0, having won the first Test in Galle by 278 runs, and only need a draw to clinch the series. South Africa has not lost a series to Sri Lanka since 2006.