Sri Lanka duo Tillakaratne Dilshan and Kumar Sangakkara shared a double-century partnership before Pakistan hit back by grabbing three late wickets on the fourth day of the second Test on Tuesday.
Replying to Pakistan's first innings 551 for six declared, the home team reached the close of play on 278 for five with Sangakkara unbeaten on 144.
Left-arm seamer Junaid Khan broke the 225-run stand for the second wicket by trapping Dilshan lbw for 121 and 14 runs later followed up with a similar dismissal of Sri Lanka captain Mahela Jayawardene.
Jayawardene did not offer a shot to a ball that came in from outside the off stump and recorded his first duck at the Sinhalese Sports Club Ground in 25 Tests.
Junaid's fiery spell of six overs gave him two for 13 and three for 56 overall.
Saeed Ajmal then claimed his first wicket when he dismissed an out of sorts Thilan Samaraweera for another duck with a delivery that hurried on to the batsman and trapped him lbw.
Pakistan first innings 551-6 dec
Sri Lanka first innings (o’night 70-1)
T. Paranavitana c Azhar b Junaid 0
T. Dilshan lbw b Junaid 121
K. Sangakkara not out 144
M. Jayawardene lbw b Junaid 0
T. Samaraweera lbw b Ajmal 0
S. Randiv lbw b Rehman 5
Total (for 5 wickets, 85.4 overs) 278
Fall of wickets: 1-11, 2-236, 3-250, 4-259, 5-278
Pakistan rounded off a superb final session when Abdur Rehman removed Suraj Randiv lbw for five in the last over.
Slow and steady
After rain had interrupted play on the second and third days, Tuesday's action began half an hour late due to overcast conditions which later gave way to bright sunshine.
Dilshan, 46 not out overnight, took his time in completing his half-century. He faced 58 balls in the morning session, adding 14 to his score without reaching the boundary once.
Sangakkara overtook his partner after going to his 50 off 74 balls.
The left-hander got a reprieve on 46 when a thick outside edge off Aizaz Cheema flew to gully Asad Shafiq but he was unable to hang on to the catch.
Shafiq left the field for treatment, having hurt his hand.
During his innings Sangakkara passed 2,000 Test runs at the ground and also became the highest Test run-getter against Pakistan, surpassing former India opener Sunil Gavaskar's aggregate of 2,089.
Sri Lanka lead the three-match series 1-0.