Pakistan 341 (Shehzad 147, Misbah 63, Herath 5-125, Eranga 4-60) and 302 for 5 (Azhar 103, Misbah 68*) beat Sri Lanka 428 for 9 dec (Perera 95, Mathews 91, Sangakkara 52) and 214 (Rehman 4-56) by five wickets
Scorecard and ball-by-ball details

Pakistan turned a Test that had been an abysmal advertisement for cricket for four days and one session on its head, with an incredible batting performance after lunch on the final day, when they scored 302 runs in 57.3 overs to sucker-punch Sri Lanka and level the series. Their run-rate of 5.25 was the second highest in a successful chase of a 200-plus target, and the protagonists of this heist - Azhar Ali, Sarfraz Ahmed and Misbah-ul-Haq - proved that the soporific pace of the previous days was entirely by design, largely Sri Lanka's to protect their 1-0 lead.

For the fifth day to have ended in a result, both teams needed to play extraordinary cricket. Pakistan were extraordinarily purposeful; Sri Lanka were extraordinarily negligent. The visitors began the day with a lead of 220 and five second-innings wickets in hand but batted so slowly, adding 19 runs in the last 16.4 overs. With a minimum of 59 overs left in two sessions Sri Lanka were still favourites, if not to win then certainly to draw, but they were ultra-defensive from the outset against a desperate Pakistan unit. As Misbah-ul-Haq's side motored towards the target with an unfamiliar efficiency, it became too late for Angelo Mathews to snap himself and his side out of stupor. Sri Lanka sank in the Sharjah twilight, with their captain and fielders feebly complaining about not being able to see the ball.

Pakistan needed 195 in 35 overs at the start of the final session, and they had made a tactical decision to send Sarfraz Ahmed in at No.5, shortly before the tea break. He proved to be the catalyst, and the method he used to attack Rangana Herath's defensive line oozed with resourcefulness.

Herath operated from over the wicket and pitched wide outside leg stump for most of his 19 overs, which cost 100 and yielded no wickets, but when he did so after tea Sarfraz took guard near the wide-ball indicators outside leg stump and lofted inside-out through covers to beat a packed on-side field. After several such shots, Mathews moved a fielder from the leg to the off, and Sarfraz promptly slogged Herath over the midwicket boundary to take 15 runs off the 29th over, the most expensive of the match.

While Sarfraz made use of his license to run riot, Azhar accumulated briskly in a more organised manner, driving the seamers and sweeping Herath off his negative line. With the field spread deep, Azhar picked off the gaps to get to his half-century off 79 balls, and his 89-run stand with Sarfraz came at a run-a-ball. Pakistan needed 116 off 22.2 overs when Misbah walked in, after Sarfraz had been caught gloving a Shaminda Eranga short ball down the leg side.

Mathews remained defensive despite having a new batsman at the crease and the 40th over of the chase, from Suranga Lakmal, was a defining one. Azhar jumped outside leg and drove, forcing a full-length dive from the deep-cover fielder, the next three balls went to deep point and deep midwicket, before Misbah pulled to the fine-leg boundary. The over cost 12 runs, and Pakistan's momentum was unaffected by Sarfraz's departure.

Despite Azhar and Misbah sweeping and reverse-sweeping Herath at will, irrespective of whether he bowled over or round the wicket, and the left-arm spinner proving utterly ineffective at controlling the run-rate, Mathews did not use his offspinner Dilruwan Perera at all.

Sri Lanka tried to stall the game in the last hour, with Eranga needing prolonged attention from the physio after his arm came into contact with Misbah's helmet, which prompted umpire Richard Kettleborough to ask the physio to stay off the ground when Lakmal fell while collecting a ball. The equation boiled down to 30 off 30 balls, and after three runs off the first two deliveries of the Lakmal over, Azhar cleared his front foot and swung to the midwicket boundary. A ball later, he celebrated a century off 133 balls. The century stand with Misbah had taken only 111.

Even when Pakistan needed 17 off four overs, the field stayed spread. Sri Lanka had actually lost the Test long before the winning runs were hit.

The base for Pakistan's final-session heroics had been laid after the lunch break, when Ahmed Shehzad and Khurram Manzoor came out swinging. As soon as Shehzad flicked Eranga for two fours in the second over and Manzoor charged and slapped Lakmal to the cover boundary in the third, Mathews dispersed his fielders. The approach was helter-skelter and fraught with risk, though. Shehzad eventually mis-hit a slower ball and was caught at deep midwicket, while Manzoor was caught nimbly down the leg side by the wicketkeeper Prasanna Jayawardene. Pakistan had got to 48 at more than five an over.

Azhar began his innings by cutting his second ball fiercely through point, but his partnership with Younis Khan was more measured. With plenty of gaps to exploit, they picked up singles and twos comfortably. They added 49 in 12.4 overs when Younis pulled Mathews straight to midwicket to leave Pakistan on 97 for 3.

Pakistan did not go on the defensive despite losing Younis. Instead, they promoted Sarfraz, and he charged and slogged Mathews to the midwicket boundary in the last over before tea, small indication of the damage he would inflict on Sri Lanka after the break.

Sri Lanka would not have suffered such an embarrassing defeat had they played more periods of this Test with a semblance of the urgency Prasanna showed for an hour this morning. After they scored at 1.87 for 71 overs on the fourth day, Prasanna led the gathering of 62 runs in 14 overs on the last morning. A few wickets, however, forced a dramatic slowdown and Sri Lanka went at a little more than a run an over for the rest of their innings. At the end of the Test, Sri Lanka had batted 273.4 overs; Pakistan needed only 166.4 overs to score a run more. There lay the difference.

George Binoy is an assistant editor at ESPNcricinfo