DUBAI: Asad Shafiq, after scoring a sure-footed century, remained the only hope as Pakistan staggered trying to save the Test series in the opening session of the final day of Dubai Test on Tuesday.
Shafiq brought up his 100 off 151 balls, as he and skipper Sarfraz Ahmed took Pakistan past 200, chasing a target of 317 in a thrilling final day of the day-night Test.
Sarfraz, however, fell to a Perera delivery for 68 off 130.
Mohammad Amir was the next to depart, leaving Pakistan at 230-7, and Shafiq survived an lbw scare soon afterwards.
On Monday, both Shafiq and Sarfraz hit fighting half-centuries to thwart Sri Lanka and set up an enthralling finish.
Shafiq scored an unbeaten 86 while Sarfraz was 57 not out as they lifted Pakistan from a perilous position at 52-5 to 198-5 at close after being set a daunting target of 317.
The pair added 146 for the unbroken sixth-wicket stand to leave Pakistan needing another 119 runs with five wickets in hand to level the series. Sri Lanka won a nail-biting first Test in Abu Dhabi by 21 runs.
Both Shafiq and Sarfraz batted confidently to raise hopes of Pakistan maintaining their unbeaten record in nine Test series in the United Arab Emirates, their adopted home since 2009.
Shafiq brought up his 19th Test fifty with a well-timed cover drive off fast bowler Suranga Lakmal, his first 50-plus score in 12 innings.
Sarfraz smashed part-timer Kusal Mendis for his fourth boundary to complete his 14th Test half-century.
Pakistan made a disastrous start when opener Sami Aslam fell for one, caught in the slips off Lahiru Gamage.
Opener Shan Masood and Azhar Ali (17) added 31 for the second wicket before the batting collapse began with Azhar caught off fast bowler Nuwan Pradeep for 17.
Earlier, paceman Wahab Riaz grabbed four for 41 and left-arm spinner Haris Sohail took three wickets in a single over to dismiss Sri Lanka for 96 in their second innings.
Watch Live Cricket on Crictime.com.pk