Amla, 31, batted for more than eight hours to frustrate the Sri Lankan spinners who shared nine wickets between them to bowl out South Africa for 282 in their first innings.
Sri Lanka, who made 421 in their first essay, were 11-0 at stumps in their second innings for an overall lead of 150.
Off-spinner Dilruwan Perera (5-69) grabbed a five-wicket haul, his second in five Tests.
Sri Lanka, who made 421 in their first essay, were 11-0 at stumps in their second innings for an overall lead of 150.
Off-spinner Dilruwan Perera (5-69) grabbed a five-wicket haul, his second in five Tests.