Sri Lanka are in prime position to claim a series win over Pakistan after Dimuth Karunaratne's 196 helped them post 482 before Pakistan reached 51/0 by stumps on day two.
The tourists resumed on 254 for 3 with Dinesh Chandimal at the wicket with Karunaratne.
Chandimal (62) followed up his hundred in the opener with another fifty but fell leg before to Yasir Shah with the score on 282.
The swashbuckling Niroshan Dickwella smashed a rapid 52 off 53 balls in an 88 run partnership with Karunaratne.
Karunaratne passed 3000 runs in Test cricket during his innings becoming only the third Sri Lanka opener to achieve the feat after Sanath Jayasuriya and Marvan Atapattu.
Dilruwan Perera (58) played out another fifty plus partnership with Karunaratne, the fifth the opener was involved in and the last of the innings.
After Wahab Riaz removed Karunaratne, Yasir Shah worked his way through the tail leaving Pakistan with 18 overs to negotiate.
Yasir would claim figures of 6 for 184 in a marathon effort that saw him bowl 55.5 overs.
Shan Masood (15) and Sami Aslam (30) got Pakistan to the close without any loss but with Sri Lanka having taken the first match the onus will be on Sarfraz Ahmed's men to move the game forward.