Pakistan's Abdullah Shafique smashed his second Test hundred to put the tourists on course to accomplish a mammoth chase on day four of the opening Test against Sri Lanka in Galle on Tuesday.
Pakistan finished Day 4 on 222/3, needing 120 more to grab the lead in the two-Test series.
Sri Lanka had appeared to have the upper hand in the contest after they posted 337 in their second innings setting Pakistan a daunting target of 342.
Shafique combined with Imam-ul-Haq (35) in an opening stand of 87 and later raised 101 with skipper Babar Azam (55) in a vastly improved batting display by the tourists who were skittled out for 218 in the first innings.
Shafique's unbeaten 112 contained five fours and a six and he had Mohammad Rizwan on seven at the other end.
However, Shafique and Imam did not look very convincing when Pakistan began their chase.
Imam was dropped at cover and had an lbw decision against him reversed, while Shafique survived a strong leg-before appeal.
Imam's innings ended in a bizarre manner when he let go a ball from spinner Ramesh Mendis but marginally lifted his back foot in the process allowing Niroshan Dickwella to effect a lightning-fast stumping.
Sri Lanka seemed back in charge when Jayasuriya had Azhar Ali caught in the slip for six.
Babar, who smashed a century in the first innings, opened his account with a flicked four off Jayasuriya and hit the spinner over deep midwicket for a six in his next over.
Shafique took a single off Maheesh Theekshana to bring up his hundred and celebrated the milestone by kissing his helmet and embracing his captain Babar.
Jayasuriya bowled Babar around his legs in the final session though Pakistan appear to have their nose ahead in the contest.