Pakistan 262 (Azhar 59, Sohail 56, Perera 3-72, Herath 3-84) and 198 for 5 (Shafiq 86*, Sarfraz 57*, Perera 3-76) needs 119 runs to beat Sri Lanka 482 (Karunaratne 196, Yasir Shah 6-184) and 96 (Wahab Riaz 4-41, Haris Sohail 3-1)
Dubai: After losing five wickets for just 52 runs, Asad Shafiq and Sarfraz Ahmed fought back with a century partnership as Pakistan finish 198 for 5 on the fourth day of the second and final day-night Test in Dubai on Monday.
At the stump Shafiq (86) and Sarfraz (57) were at the crease as Pakistan, needing another 119 runs to win for avoid their first series defeat in United Arab Emirates since adopting it as their home venue in 2009.
Off-spinner Dilruwan Perera took three wickets. Perera dismissed Haris Sohail (ten), Shan Masood (21) and Babar Azam (nought) to leave Pakistan in tatters on 62-5 at dinner.
But Pakistan captain and Shafiq added unbeaten 146 runs for sixth wicket.
Pakistan were forced to play at neutral venue since 2009 terrorists' attacks on the Sri Lankan team suspended international cricket in their country.
Sri Lanka had won the first Test by 21 runs in Abu Dhabi.
Pakistan were off to a disastrous start when opener Sami Aslam fell for one, caught in the slip off paceman Lahiru Gamage.
Masood and Azhar Ali (17) added 31 for the second wicket before the wicket slide began with Ali caught off paceman Nuwan Pradeep for 17.
Earlier, paceman Wahab Riaz grabbed 4-41 and left-arm spinner Haris Sohail took 1-3 to dismiss Sri Lanka for 96 in their second innings after they resumed at 34-5.
Pakistan needed early gains and Riaz provided them with the important wicket of Niroshan Dickwella in the fifth over of the day for 21.
Leg-spinner Yasir Shah dismissed Dilruwan Perera for nought to leave Sri Lanka in danger of being dismissed for their lowest ever total of 71 against Pakistan.
But Kusal Mendis (29) and Rangana Herath (17) added 35 for the eighth wicket to frustrate Pakistan before Sohail struck thrice in his only over to give his team hope of an upset win.
Shah finished with 2-47.