Sri Lanka lost batsman Kaushal Silva in the final over of the day after his 81 had edged them into the lead against Pakistan on day three of the first Test in Abu Dhabi.
Silva had taken Sri Lanka to a lead of just seven runs when he fell to Junaid Khan to leave the tourists on 186-4 in their second innings at the close of play.
Junaid's full length ball outside off stump tempted Silva into a low edge which was taken down near his left foot by wicketkeeper Adnan Akmal halfway through the 62nd over.
Sri Lanka had earlier bowled Pakistan out for 383 as the 'home' side added just 56 runs for the loss of six wickets in the morning session.
Starting the day on 327-4, Pakistan were back in the pavilion before lunch as they failed to build on a commanding second day.
Misbah-ul-Haq top-scored in the session as he added 30 to his overnight 105, but despite the collapse Pakistan still boasted a lead of 179.
Sri Lanka take great credit for fronting up, though, with Rangana Herath taking three of the wickets to fall, including the vital one of Misbah who was clearly in the mood to tee off and add as many runs as he could.
His 135 came from a vigilant 306 balls and it was a good job he and day two centurion Younis Khan (136) had dug in as the next highest score was Ahmed Shehzad's 38.
Sri Lanka, who had scored 204 in their first innings, returned to the middle for one over before lunch was called, navigating their way through that for two runs.
But when they lost Dimuth Karunaratne for 24, bowled by Junaid, the total had reached 47.
Kumar Sangakkara had scored 55 when he was caught by Younis Khan off the bowling of Bilawal Bhatti and Sri Lanka were 146-2.
Bhatti struck another important blow shortly afterwards as he removed the dangerous Mahela Jayawardene for a duck with Asad Shafiq this time taking the catch.
Silva, his 81 including 11 fours, fell after putting on 36 for the fourth wicket with Dinesh Chandimal, the latter ending the day unbeaten on 24.
But with Sri Lanka only seven runs ahead and with six wickets remaining, Pakistan are strong favourites to win the Test ahead of day four.