Chasing 136 at Abu Dhabi, Pakistan lost what seemed to be an un-losable Test. Having been 52 for 5 in the pursuit of 317, they have now left themselves a chance of winning what appeared to be an unwinnable one. In a series that has been enlivened by a flood of dramatic twists, the final session of day four saw another one: an unbroken partnership of 146 between Asad Shafiq and Sarfraz Ahmed.
Sri Lanka still have five wickets to get. Pakistan 119 runs to square the series. If the visitors break through, it will be the first time since 2010 that Pakistan have been defeated in the UAE. If Pakistan get across the line, it would be their third 300-plus chase against Sri Lanka in four years.
Late in the twilight session, Dilruwan Perera had claimed three wickets inside 10 deliveries, to spark elation in the Sri Lanka camp and despondence in Pakistan's, but following a wicketless night session, it was Pakistan who appeared the more hopeful outfit. Sarfraz and Shafiq had navigated an immensely difficult period more-or-less perfectly.
Sarfraz had been the more proactive batsman early on in the partnership, nailing a flat sweep off Herath to the backward square leg fence, before carving Dilruwan through point a few overs later, but when Shafiq had played himself in, he quickly became the dominant figure in the stand.
Off his 26th ball, Shafiq waltzed down the pitch to launch his first boundary, hitting Dilruwan over mid-on. Almost immediately, the singles and twos began to flow. Midwicket, fine leg, long-on - these areas were all mined for valuable runs, and the cover boundary proved productive for Shafiq as well.
Sarfraz stayed largely leg side, hitting only two further boundaries in the day, after those early momentum-shifting blows against the spinners. As ever, he flitted around on the crease, even batting way outside leg stump to one delivery, and used the sweep to fruitful effect. At times in this series, Sarfraz has been overtaken by reckless impulses. Not in this innings. Like Shafiq, he was opportunistic, but calculated. They ran quick singles into the infield, but Sarfraz repeatedly sent Shafiq back when he felt a run was too risky.
Towards the second half of the session, Dinesh Chandimal spread his fields, and the pair progressed with increasing ease. Between the 50th and 65th overs of the innings, for example, they scored 70 risk-free runs. Shafiq moved past fifty with a cut off Suranga Lakmal, and later, Sarfraz got there with a dismissive pull off the part-time legspin of Kusal Mendis.
Rangana Herath, Pakistan's great tormentor from Abu Dhabi, was not only wicketless in the innings, he was also defused with surprising alacrity during this partnership. The pitch had worn, certainly, but had not become a minefield yet. By stumps, Shafiq had cruised to 86 off 141 balls. Sarfraz was on 57 off 113.
They had each earlier given chances off successive balls, to Mendis at short leg, but the catches - both very difficult - were grassed. But that was when Shafiq was batting on 26, and Sarfraz on 22. No one imagined then, that the missed opportunities would cost Sri Lanka so much.
That Pakistan could dream of chasing down a score at all, was thanks to their bowlers, who had ensured the dramatic collapse they had set in motion late on the third day, continued into the first session on day four.
It was the inscrutable Wahab Riaz who recommenced the wicket-taking, having Niroshan Dickwella brilliantly caught by Sarfraz, who dived to his left to pouch the ball one-handed. Herath and Mendis mounted a 35-run partnership, and even hit Yasir out of the attack, but then another twist.