In a chanceless six hours at the crease, Jayawardene finished on 140 not out made off 225 balls including one six and 16 fours to give Sri Lanka a solid start in their bid to level the two-match series.
It was Jayawardene’s 34th test hundred and his 11th at this ground. Debutant Niroshan Dickwella was unbeaten on 12 at the close.
South Africa picked up two wickets in the final session, dismissing captain Angelo Mathews for 63 and Kithuruwan Vithanage for 13.
Mathews, attempting to cut JP Duminy, gave wicketkeeper Quinton de Kock a catch to end a fourth-wicket partnership of 131 with Jayawardene.
Vithanage never looked comfortable against short-pitched deliveries and was hit on his visor by Dale Steyn.
He eventually fell to a sharp rearing delivery from Morne Morkel which he fended to AB de Villiers at third slip.
Jayawardene joined Indian Sunil Gavaskar and West Indian Brian Lara on 34 test centuries, reaching the milestone in the final over before tea when he swept a Dean Elgar full toss for two.
The South African bowlers toiled on an unresponsive batting pitch at the Sinhalese Sports Club as Sri Lanka added 97 runs in the afternoon session.
Steyn, man-of-the-match in South Africa`s 153-run victory in the first test at Galle, rocked Sri Lanka in the morning, sending back Upul Tharanga for 11 and Kumar Sangakkara for a golden duck with short-pitched deliveries.
Tharanga gloved a catch to De Kock as he failed to avoid from a rising ball and Sangakkara fluffed a pull and top-edged a simple catch to Imran Tahir at square leg.
South Africa captured the wicket of Kaushal Silva (44) in the last over before lunch when the batsman edged a Duminy delivery to De Villiers at slip.