Pakistan 329 for 7 (Shehzad 103, Alam 74, Afridi 59, Hafeez 52) beat Bangladesh 326 for 3 (Anamul 100, Kayes 59, Mominul 51, Mushfiqur 51* ) by three wickets
Scorecard and ball-by-ball details

Agarkar: Afridi unstoppable in this form
Agarkar: Afridi unstoppable in this form

Ahmed Shehzad's fifth ODI century set it up, but Pakistan needed special innings from Fawad Alam and Shahid Afridi, who blazed an 18-ball fifty, to pull off their highest chase in ODIs and book a place in the Asia Cup final, against Sri Lanka.

Afridi ransacked 59 off 25 balls, hitting seven sixes during a 69-run stand for the sixth wicket with Fawad Alam that took only 5.3 overs. They resurrected a flagging Pakistan chase, after Bangladesh had surpassed expectations to post 326 for 3, their best ODI score. The game was decided with only one ball to spare.

Bangladesh's bowling and fielding let them down - they were sloppy on the boundary and Mushfiqur Rahim dropped Afridi on 52 in the final moments - and they failed to defend 300-plus for the first time in four attempts.

Pakistan's chase was led by Shehzad, who made 103 off 123 balls, accelerating after a sedate start and adding 105 runs for the fourth wicket with Fawad at 6.70 per over. He fell in the 39th over, and after the curious promotion of Abdur Rehman as pinch-hitter failed, only Afridi could make or break the game. Pakistan needed 102 off 52 balls, and he smote the ball so hard and far during an assault that will not be forgotten by those at the Shere Bangla Stadium. Several faces in the crowd revealed anguish as Afridi bludgeoned the home side.

Between overs 41.2 overs and 46.5, when he was finally run out, Afridi launched sixes over long on, extra cover, long off, midwicket and fine leg. Five of his seven sixes came in his first nine deliveries. His stand with Fawad came at 12.54 an over. He took the bowling and Mirpur by surprise. During the onslaught from Afridi and Fawad, Mahmudullah gave 16 in an over, Shakib 20, Shafiul 16 and Razzak 18 as the asking rate plummeted in the last ten overs.

When Afridi was dismissed, struggling with cramp, Pakistan still needed 33 off 19 but Fawad stepped up, clouting Razzak twice over the midwicket boundary to kill the contest. The turnaround Afridi engineered had been so sudden because Pakistan had lost their way after a 97-run first wicket stand between Shehzad and Mohammad Hafeez, as three wickets fell for eight runs.

Unlike their bowling that fell apart, however, Bangladesh's batting had been impeccable. For the first time since the Fatullah chase against New Zealand in November last year, every batsman's plans worked.

Anamul's century played the central role and he made sure Pakistan were denied early wickets. Despite his reputation as a shot-maker, his 132-ball knock was chanceless, and he played second fiddle during the early stages of his 150-run opening stand with Imrul Kayes, who rode his luck to score a half-century in his comeback game. Kayes was dropped on 0 in the first over and survived a close leg-before appeal in the seventh, but he still looked for boundaries. Anamul caught up with him, and the pair laid into Pakistan during two hitting sprees.

Imrul struck Afridi for two sixes over midwicket while Anamul attacked Mohammad Talha, Pakistan's best bowler from the match against India. In the 16th over, Anamul moved from 41 to 57 with three consecutive boundaries - a six, a four and another six - all with the pull shot. It ruined Misbah's plans because Pakistan had already lost Abdur Rehman because he bowled three beamers before he had delivered a single legal delivery.

It got worse when Saeed Ajmal and Afridi struggled too, and Umar Gul was poor in the slog overs. Anamul reached his hundred in the 39th over but got out soon after. He had laid the platform and then watched Mushfiqur Rahim and Mominul Haque reach fifties, and Shakib smash 44 off 16 balls after returning from a three-match ban. Bangladesh took 121 runs off the last ten overs but even that was not enough to survive a battering from Afridi.

This loss will hurt Bangladesh as much as the one against Afghanistan did and they have only pride to play for in the final league game against Sri Lanka. Pakistan, on the other hand, were deserving finalists, having clinched last-over finished against both India and Bangladesh.

Mohammad Isam is ESPNcricinfo's Bangladesh correspondent. He tweets here