The 36-year-old (106 not out) added 91 for the unbroken fifth wicket with captain Angelo Mathews (42 not out) to take Sri Lanka to 318 for four at the close on the second day, a first-innings lead of 153 runs.
The stylish right-handed batsman, who was injured while fielding at slip on the opening day, punched the air in delight after reaching the century mark with a delicate late cut boundary off fast bowler Bilawal Bhatti.
Jayawardene had last scored a Test hundred in April 2012 against England at home and had been dismissed cheaply by Bhatti in both innings of the drawn first Test in Abu Dhabi.
He also added 139 with opener Kaushal Silva (95), who fell short of his maiden Test hundred, for the fourth wicket after Pakistan had pegged back Sri Lanka with two early strikes in the morning.
The Pakistan bowlers toiled hard but failed to dislodge the pair as Sri Lanka remained unscathed in the afternoon session.
Part-time off-spinner Mohammad Hafeez finally broke the partnership when he dismissed Silva leg before after the batsman failed to connect with a sweep shot.
The diminutive right-hander trudged back to the dressing room after an unsuccessful attempt to review the umpire's decision.
Jayawardene, on 26, successfully overturned an lbw decision off paceman Rahat Ali on review while wicketkeeper Sarfraz Ahmed dropped an edge from Mathews later off the same bowler to add to Pakistan's frustration.
Rahat had struck early to send back Kumar Sangakkara (26) leg before while his fast bowling colleague Junaid Khan dismissed Dinesh Chandimal (12), batting at number four due to Jayawardene's injury, to reduce Sri Lanka to 88 for three.
Yet frontline spinner Saeed Ajmal's failure to trouble the batsmen and a docile pitch ensured Sri Lanka took a healthy first-innings lead.
Scorecard
Pakistan first innings 165
Sri Lanka first innings (overnight 57-1)
D. Karunaratne lbw b Junaid 32
K. Silva lbw b Hafeez 95
K. Sangakkara lbw b Rahat 26
D. Chandimal c Rahat b Junaid 12
M. Jayawardene not out 106
A. Mathews not out 42
Extras (b-1, lb-2, w-1, nb-1) 5
Total (four wickets; 106 overs) 318
Fall of wickets: 1-40, 2-75, 3-88, 4-227
Bowling (to date): Junaid 26-5-75-2, Rahat 26-5-109-1, Ajmal 27-9-45-0, Bilawal 21-3-75-0 (1nb, 1w), Hafeez 6-1-11-1
Image: Mahela Jayawardene
Photograph: Tom Shaw/Getty Images
Bhatti and Junaid bowl Pakistan into strong position
Pakistan toil as Mathews ton gives Sri Lanka solid lead
Pakistan's Junaid, Bhatti restrict Sri Lanka to 204
US releases pics of civilian deaths during Lankan civil war
Hafeez, Shehzad score fifties as first Test ends in draw