Dinesh Chandimal helped Sri Lanka earn a handy first-innings lead against Pakistan, whose strong reply left the second and final test evenly poised in Karachi on Friday.
Chandimal scored 74 and forged half-century partnerships with Dhananjaya de Silva and Dilruwan Perera to help Sri Lanka post 271 all out, a lead of 80, on the second day at Karachi's National Stadium.
Pakistan, bundled out for 191 in the first innings, cruised to 57 for no loss with openers Abid Ali (32) and Shan Masood (21) looking unperturbed against the Sri Lankan attack.
Earlier, Shaheen Afridi claimed his maiden five-wicket haul and Mohammad Abbas returned 4-55 to restrict Sri Lanka to a sub-300 total and keep the hosts alive in the contest.
Resuming on 64-3, Sri Lanka lost both overnight batsmen cheaply.
Abbas fired two bouncers at Lasith Embuldeniya before dismissing the nightwatchman with a slower delivery and Afridi accounted for Angelo Mathews who was caught behind for 13.
Chandimal added 67 runs with de Silva, who made 32 before fluffing his pull shot against Afridi.
Chandimal hit a four off Abbas to bring up his fifty and put Sri Lanka ahead but a century eluded him.
The right-hander, who hit 10 boundaries, perished at backward point trying to play a cut shot off spinner Haris Sohail.
Perera, who was hit on the helmet grill by an Afridi delivery, made a defiant 48 before falling to the quick who claimed the last two Sri Lankan wickets in three deliveries.
The two-match series, part of the World Test Championship, marks Pakistan's first tests on home soil since the 2009 militant attack on Sri Lanka's team bus in Lahore.
The weather-hit opening test at Rawalpindi ended in a draw.