South Africa have lost three wickets before the close of play to hand Sri Lanka the advantage after day two of the second Test match in Colombo.
Sri Lanka resumed the day on 305-5, but after reaching lunch in a dominant position, they lost their final four wickets for 17 runs to end their innings on 421.
However, the hosts struck early in the South Africa innings when Alviro Peterson fell to Rangana Herath before Dean Elgar soon followed to leave their side on 13-2.
A 58-run partnership between Faf du Plessis and Hashim Amla steadied the ship for the visitors, but after Du Plessis fell for 36, Amla batted out the remainder of the day to see South Africa finish on 98-3, still 323 runs adrift of Sri Lanka.