Mahela Jayawardene remained unbeaten on 49 in his farewell innings after spinner Rangana Herath's career best figures of 9 for 127 gave Sri Lanka control of the second cricket test against Pakistan.
Jayawardene, playing his last test, added 98 for the unbroken third wicket with his long-standing partner Kumar Sangakkara (54 not out) as Sri Lanka ended the third day against Pakistan on 177 for 2.
Sri Lanka, leading the two-test series 1-0, took an overall lead of 165 runs with eight second innings in hand and two days of the test match remaining.
Sangakkara and Jayawardene negotiated the Pakistan bowling, without injured Junaid Khan, skillfully on a turning track to put their team in a strong position at the end of the day.
Left-handed Sangakkara, who hit four boundaries, reached his 51st test half century before the close.
He survived a close call on 19 when Pakistan unsuccessfully reviewed a not out leg before appeal off Wahab Riaz with replays showing the ball hitting leg stump.
Jayawardene, with whom Sangakkara has associated in 46 half-century partnerships, hit seven fours during his 123-ball knock.
The 37-year-old was cheered by the sizeable crowd for every run he scored after walking out for his last test knock to a standing ovation and a guard of honour by the Pakistan players.
Left-arm spinner Abdur Rehman dismissed the Sri Lankan opener Upul Tharanga (45) and Kaushal Silva (17) in the afternoon session.
Tharanga hit four boundaries in his 63-ball innings before he dragged the ball on to his stumps while attempting a pull, ending an opening stand of 54 with Silva.
Silva fell to a catch at slip by Younus Khan.