Abu Dhabi - Opening batsman Ahmed Shehzad struck his maiden test hundred but Pakistan's hopes of a series-equalling victory looked distant on the third day of the third and final test on Saturday.
Trailing 1-0 in the three-match series, Pakistan were 291 runs for six wickets at the close, still needing 137 runs to wipe off their first innings deficit.
Captain Misbah-ul-Haq (36) was unbeaten at the crease as wicketkeeper Sarfraz Ahmed (five) fell on the final delivery of the day to give left-arm spinner Rangana Herath his third wicket of the innings.
Resuming on their overnight score of 19 for no loss, Shehzad (147) and his opening partner Khurram Manzoor (52) made a watchful start and went unscathed in the morning session.
The pair added 114 runs for the first wicket before Manzoor was caught down the leg side off paceman Shaminda Eranga.
Number three batsman Azhar Ali (eight) became debutant Dilruwan Perera's first test wicket when he edged the off-spinner to slip.
The 22-year-old Shehzad, however, kept his calm at the other end and kept accumulating runs.
The right-handed batsman added 40 for the third wicket with Younus Khan (17) before his senior partner was smartly caught by wicketkeeper Prasanna Jayawardene off Herath.
Shehzad drove Perera elegantly for a couple of runs to reach his maiden hundred in his third test and celebrated the occasion in front of a sparse crowd with a leap.
Pakistan's scoring rate improved with the arrival of Misbah at the crease and once Shehzad started playing more freely after completing his century.
But Shehzad was out while looking for quick runs as he dragged on Herath to his stumps, attempting a reverse sweep shot off a wide delivery.
Sri Lanka, who won the second test in Dubai after the first match in Abu Dhabi ended in a draw, dismissed Asad Shafiq (18) and Sarfraz cheaply before the close to take the upper hand.