A watchful first Test century for Azhar Ali took Pakistan to 281 for four at close on the second day of the second Test, on Thursday, and past Sri Lanka's first innings total of 239.
Azhar endured a torrid time in the 'nervous nineties', thrashing his bat in frustration on several occasions after failing to capitalise on loose deliveries, but eventually reached the milestone from 229 balls.
The 26-year-old faced a further 13 balls without adding to his 100 runs and was unluckily dismissed lbw off the slow bowling of captain Tillakaratne Dilshan despite a bottom edge onto his pads.
Captain Misbah-ul-Haq provided able support in their 94-run stand, notching an unbeaten 40 to leave Pakistan 42 runs ahead of their Asian rivals after cautiously adding 239 runs from 90 overs to their overnight score of 42 without loss.
Pakistan, hosting the three-Test series in the Gulf region due to security concerns at home, had also dominated the opening day's play to dismiss Sri Lanka relatively cheaply on Wednesday.
Early on Thursday Sri Lanka medium pacer Dhammika Prasad removed the Pakistan openers in quick succession, first sending a full delivery across Taufeeq Umar (27) who could only edge behind to give debutant wicketkeeper Kaushal Silva his first catch in Test cricket.
Two overs later, Prasad struck again when he dismissed Mohammad Hafeez lbw for 33 when the right-hander misjudged a sharp delivery that came back from outside off and rapped his pads in front of the stumps.
Azhar added 117 for the third wicket with Younis Khan (55), who edged onto his stumps shortly before the tea interval at the Dubai International Stadium.
The former captain had looked untroubled, bringing up his 50 by hoisting Dilshan over the rope for six; however, the spinner had the last laugh when he dismissed Younis a short while later.
Sri Lanka battled to earn a draw in last week's first Test in Abu Dhabi while the third and final match of the series will be played in Sharjah from November 3.
While the match was going on, jurors in London retired to consider their verdict in the match-fixing trial of Pakistan cricketers Salman Butt and Mohammad Asif, who are accused of plotting to bowl deliberate no-balls against England last year.
Sri Lanka (1st innings): 239 (K. Sangakkara 78; U. Gul 3-78, S. Ajmal 3-45)
Pakistan (1st innings): (overnight 42-0)
M. Hafeez lbw b Prasad 33
T. Umar c Silva b Prasad 27
A. Ali lbw b Dilshan 100
Y. Khan b Dilshan 55
Misbah-ul Haq not out 40
Saeed Ajmal not out 5
Extras: (b-6, lb-10, w-2, nb-3) 21
Total: (four wickets; 99 overs) 281
Fall of wickets: 1-63 2-64 3-181 4-275
To bat: A. Shafiq, A. Akmal, U. Gul, S. Ajmal, J. Khan, A. Rehman
Bowling: Welegedara 20-4-50-0 (1w), Prasad 20-1-73-2 (3nb), Herath 23-3-56-0, Lakmal 20-7-38-0 (1w), Dilshan 16-1-48-2.