Sri Lanka were 5-305 at stumps on Thursday's first day of the series-deciding second and final Test against South Africa in Colombo.
Mahela Jayawardene, who came in with the home side reeling at 2-16, was unbeaten on 140 with Niroshan Dickwella not out 12.
Jayawardene cracked his 34th century and his 11th ton at his home SSC ground - the most by any batsman at a single venue. He led the fightback after the loss of three wickets in the morning session on a docile track.
The stylish right-hander, due to retire from Test cricket next month, also shared a 99-run partnership with opener Kaushal Silva (44).
Skipper Angelo Mathews, who promoted himself up the batting order, made 63 before being caught behind by wicketkeeper Quinton de Kock off the bowling of part-time spinner JP Duminy.
Morne Morkel then picked up Kithuruwan Vithanage for 13.
Earlier, fast bowler Dale Steyn (2-55), the star of South Africa's big win in the first Test in Galle, sent back opener Upul Tharanga (11) and Kumar Sangakkara for a duck with consecutive deliveries in a sharp four-over opening spell.
Much to the disappointment of home fans, prolific left-hander Sangakkara tried to pull a short Steyn delivery, only to top-edge it tamely to square leg where Imran Tahir took an easy catch.
South Africa won the opening game in Galle to go 1-0 up in the series.
Share
