Left-arm paceman Junaid Khan also picked up opener Kaushal Silva for 81, caught behind, with the last delivery of the third day to reduce Sri Lanka to 186 for four in their second innings, a lead of seven runs. (Agencies)
Dimuth Karunaratne (24) put on 47 runs for the opening wicket with Silva before he was bowled by Junaid.
Silva and Sangakkara (55) then put on 99 for the second to get Sri Lanka close to wiping out the first innings deficit of 179.
Bhatti, who took three wickets in the first innings, extracted lively pace and bounce off the wicket and got left-hander Sangakkara to edge a catch to Younus Khan at first slip on the last delivery of his over.
He returned to have Jayawardene caught for a duck off the first ball of his next over to dent Sri Lanka's chances of a big second innings total.
Pace duo Shaminda Eranga (three for 80) and Suranga Lakmal (two for 99) had led Sri Lanka's fightback in the morning as Pakistan lost their last six wickets for 54 to be all out for 383.
Needing quick wickets in the first session to keep Pakistan's lead under check, Lakmal sent back Asad Shafiq (13) after the batsman had just added a run to his overnight score.
Shafiq flicked Lakmal to square leg where Silva completed a diving catch.
Wicketkeeper Adnan Akmal (six) also went quickly, edging Eranga to gully, before Bhatti (14) was adjudged caught behind after Sri Lanka captain Angelo Mathews asked a review of the umpire's not out decision.
Left-arm spinner Rangana Herath, who had looked largely ineffective till then, mopped up the last three wickets in four balls to end the innings.
Saeed Ajmal and Rahat Ali were out leg before and bowled respectively in consecutive deliveries while Pakistan captain Misbah-ul-Haq (135) was the last man to fall.
Misbah added 30 to his overnight score before holing out in the deep to Sangakkara while looking for quick runs.
Left-arm paceman Junaid Khan also picked up opener Kaushal Silva for 81, caught behind, with the last delivery of the third day to reduce Sri Lanka to 186 for four in their second innings, a lead of seven runs.