Amla, 31, dug in with a painstaking 46 off 134 balls as South Africa trailed the hosts by 323 runs with seven wickets in hand on the second day of the Test at the SSC ground in Colombo.
At stumps, South Africa were 98-3 with AB de Villiers (11) being the other not out batsman at the crease.
Amla is leading the South African team for the first time in this two-Test series after being named captain last month following the retirement of Graeme Smith.
Sri Lanka posted 421 in their first innings, thanks to a solid 165-run knock by Mahela Jayawardene and a defiant 72 by Test debutant Niroshan Dickwella.
South Africa were off to a shaky start in their first innings, losing their openers inside the first nine overs before seamer Suranga Lakmal sent back Faf du Plessis for a fighting 36.
Left-arm spinner Rangana Herath gave the side an early breakthrough when he caught opener Alviro Petersen off his own bowling in the second over for two.
Amla and du Plessis tried to rebuild the innings with some patient batting but Lakmal broke their 58-run stand half an hour before close.
Du Plessis tried to swing a widish delivery from Lakmal but edged it to Dickwella who dived to his left to take a one-handed catch just inches off the ground.
South Africa wrapped up the Sri Lankan innings in the second session, starting with the dismissal of Perera who lobbed a simple catch to Amla off leg-spinner Imran Tahir (1-121).
