South Africa need six more wickets with two days still to play to win the second cricket Test against Sri Lanka, who closed the third day on 130 for four, still 377 runs behind the hosts' mammoth target.
Vernon Philander and Kagiso Rabada both took two wickets as the home team closed in on victory and an unassailable 2-nil lead in the series.
South Africa have ample time to whittle away the rest of the Sri Lankan batting while the visitors, set 507 runs to win, must survive six more sessions if they are to force a most improbable outcome.
Angelo Mathews (29 not out) and Dinesh Chandimal (28 not out) will resume at the crease on Thursday Night (NZ time), having shown some resistance to the close of play with an unbeaten 61-run partnership.
South Africa eye up Australia for 2018
South Africa and Australia will contest a four-test series for the first time in almost 50 years when they clash in March and April 2018.
Australia will tour South Africa seeking revenge for their 2-1 home series loss in November and will play four tests for the first time since being humbled 4-0 on South Africa soil in the 1969/70 season.
Since South Africa's readmission to international cricket in 1991 the sides have met in only two- or three-test series.