Mahela Jayawardene remained unbeaten on 49 in his farewell innings after spinner Rangana Herath's career-best figures of nine for 127 gave Sri Lanka control of the second 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 two wickets.
Sri Lanka innings 320
Pakistan first innings 332
Sri Lanka second innings
U Tharanga b Rehman 45
K Silva c Younis b Rehman 17
K Sangakkara not out 54
M Jayawardene not out 49
Extras (b9 lb1 nb1 w1) 12
Total (for 2 wickets, 63 overs) 177
Fall of wickets: 1-54, 2-79
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 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.
Earlier, Herath's heroics restricted Pakistan's first innings lead to 12 runs with wicketkeeper Sarfraz Ahmed scoring his maiden Test century.
Pakistan were all out for 332 at the stroke of lunch, replying to Sri Lanka's first innings total of 320.
The visitors' last four wickets added 88 runs to their overnight score of 244 for six, with Sarfraz (103) moving from 66 to his hundred with a superb pulled six off Chanaka Welegedara to become the first Pakistani wicket-keeper in five years to get to three figures.
Herath's morning spell on Saturday was four for 29 off 8.1 overs. He became only the second Sri Lankan bowler to take nine wickets in an innings after former off-spinner Muttiah Muralitharan.