South Africa were 234-7 at tea on the third day of the second Test against Sri Lanka on Saturday.
Hashim Amla's century, his first against Sri Lanka and his 22nd in Test cricket, has stood in the way of the hosts and wiped out the follow-on.
The hosts, however, still hold the upper hand, as their opponents trail by 187 runs.
Scores: Sri Lanka 421 (Mahela Jayawardene 165, Niroshan Dickwella 63; Vernon Philander 2 for 52) lead South Africa 234 for 7 (Faf du Plessis 36, Hashim Amla 119, AB de Villiers 37; Dilruwan Perera 4 for 58) by 187 runs.