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 rounded off a superb final session when Abdur Rehman removed Suraj Randiv lbw for five in the last over.
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.