The opening pair of Shan Masood and Abid Ali scored 57 runs from 14 overs and left the hosts in the red by just 23 runs.
Pakistan's openers nullified Sri Lanka's first innings lead of 80 runs to leave the second Test firmly in the balance after day two in Karachi.
The day began with Sri Lanka resuming on 64 for 3 in response to Pakistan's first innings total of 191 but they quickly slid to 80 for 5 as both overnight batsmen Lasith Embul-Deniya and Angelo Mathews were caught behind.
However, the rest of the Lankan batting lineup led by former captain Dinesh Chandimal made the hosts work hard for the remaining wickets.
Chandimal shared a 67-run stand with Dhananjaya de Silva for the sixth wicket and then a 37-run partnership with Niroshan Dickwella for the seventh wicket.
Chandimal then combined with Dilruwan Perera for another half-century stand that erased Sri Lanka's deficit but a loose shot to Haris Sohail saw him fall for 74.
Perera went on to score 48 and led the visitors to 271 before Shaheen Shah Afridi wrapped up the innings with twin strikes for his maiden five-wicket haul.
At that point, the advantage was firmly with Sri Lanka but Pakistan were back level by stumps as the opening pair of Shan Masood and Abid Ali scored 57 runs from 14 overs and left the hosts in the red by just 23 runs.