Afridi hit back-to-back sixes to secure a final-over win over India on Sunday, and an 18-ball half-century was no less important against the tournament hosts as Pakistan scraped home with a ball to spare.
Pakistan will now meet Sri Lanka in Saturday's final at the Shere Bangla National Stadium.
A century from opener Ahmed Shehzad (103) set the foundation for the pursuit of Bangladesh's 326 for three, although quickfire scoring from Fawad Alam (74) and Afridi (59) was needed after a sluggish start.
Anamul Haque hit his second ODI century for Bangladesh with Imrul Kayes, Mominul Haque and Mushfiqur Rahim all passing 50.
Their efforts looked likely to be enough to pull off a surprise win - and keep alive their final hopes - when it initially appeared Shehzad had mis-timed the chase.
The 22-year-old opener crawled to his half-century from 87 balls and with 20 overs remaining Pakistan required a further 182 runs.
But Shehzad then raced through the gears to dramatically increase the tempo, his next 50 taking only another 30 balls, before Afridi and Alam took over.
Afridi picked up where he left off against India, swiping two of his first three balls over the fence.
The all-rounder took just 18 balls to get to his 50 and hit seven sixes and two fours in total before he was run out after cramping up.
Fawad passed his half-century too and after restricting the target to just three from the final over, the chase appeared firmly in hand.
There was, however, more late drama in store as Umar Akmal managed to take just one from the first three balls, before Alam was then run out at the non-striker's end trying to steal a single to the keeper.
Akmal finally finished the game, from the penultimate ball, by slogging Al-Amin Hossain to the mid-wicket rope.
- Sports & Recreation
- Fawad Alam
- Ahmed Shehzad
- Anamul Haque