Defending a par total of 265, the Tigers' first ODI of the year seemed destined for a bitter end until the strapping pacer grabbed four wickets in his last two overs to finish things off in style.
Riding on an imposing 144-run third wicket stand between Hashmatullah Shahidi (72) and Rahmat Shah (71), the touring team were in cruise control on 189-2 in 40 overs - just 77 runs shy of what would have been a famous victory.
Bangladesh skipper Mashrafe Bin Mortaza then threw the ball at Shakib Al Hasan who gave his team a much-needed breakthrough - the wicket of Shah - to trigger the Afghanistan collapse.
With runs still coming thick and fast, Taijul Islam spun up another crucial break with the wicket of Shahidi but veteran batsman Mohammad Nabi still posed a formidable threat for the hosts.
Afghanistan were 27 runs away with three overs and five wickets to spare.
But Taskin, who had conceded 49 from his last six overs, then unleashed a series of flawless yorkers to turn the tide of the match.
He reaped the rewards by seeing the back of Nabi (30 off 24 balls) and captain Asghar Stanikzai (10) in the 47th over.
Earlier, a below-par effort and an inspiring fightback from the Afghans late in the innings restricted the Bangladesh total after Mashrafe elected to bat.
Half-centuries from Tamim Iqbal (80), Mahmudullah (62) and a 40-ball 48 from Shakib were the bright spots in their batting.
Bangladesh batsmen, however, benefitted from some slapdash fielding from the Afghans, but the hosts nearly matched their opponents from the landlocked country with some poor showing of their own.
Mashrafe and his men suffered a lapse at the outset of Afghanistan's chase when Imrul Kayes put Mohammad Shahzad down at the slips with the batsman yet to open his account.
The reprieve allowed the wicketkeeper-batsman to give his team a fluent start before he fell to Mashrafe in the eighth over.
Talismanic allrounder Shakib then matched his batting prowess with the ball and struck in his first over to go level with Abdur Razzak's record for most ODI wickets (207) for Bangladesh and become the country’s top wickettaker across all formats.
Although Bangladesh failed to stage a late onslaught at the death, Tamim's knock resonated with his imperious form over the last year as he shared two prolific partnerships with Kayes (37) and Mahmudullah.
Tamim, dropped on 30, played a composed knock, gathering runs all around the ground and cracking nine boundaries in 98-ball innings.
Bangladesh, however, had begun poorly, losing Soumya Sarkar for a duck in the first over. But Tamim and Kayes paired in an 83-run stand to regain the impetus.
Kayes looked edgy at the beginning but slashed away at deliveries offering any amount of room, surviving a couple of half chances early on.
On a track that produced reasonable turn and bounce, Stanikzai introduced Nabi's offbreak in the sixth over.
The outfield was slow and muddy after heavy rain on Saturday but with both batsmen looking to regain their best touch, strike rotation never looked to be a plan.
Nabi then took out Kayes, going through the gates with a drifter to break the dangerous-looking stand and in came Mahmudullah.
Tamim forged ahead to reach his 33rd fifty in the format with an exquisite late cut to steer Bangladesh past 100 in the 23rd over.
Mahmudullah was watchful to begin with but with Tamim on song at the other end, they guided Bangladesh safely through the midovers.
Stanikzai looked to unsettle the batsmen by regularly changing bowlers at either end and managed to rein in the run rate.
Tamim departed soon, holing out at long on but Mahmudullah took charge and hammered 16 off a Dawlat over which included one of the two sixes of the innings - both hit by the 30-year-old batsman.
Dawlat was the pick of the bowlers for Afghanistan, returning 4-73 in 10 overs.
Bangladesh: 265 allout in 50 overs (Tamim 80, Soumya 0, Kayes 37, Mahmudullah 62, Shakib 48, Mushfiq 6, Sabbir 2, Mashrafe 4, Taijul 11, Taskin 2, Rubel 1 not out; Dawlat 4-73, Naveen 62-1, Ashraf 1-51, Rashid 2-37)
Afghanistan: 258 allout in 50 overs (Noori 9, Shahzad 31, Rahmat 71, Shahidi 72, Nabi 30, Nazibullah 7, Stanikzai 10, Rashid 7, Ashraf 3, Dawlat 2, Naveen 0 not out; Mashrafe 2-42, Taskin 4-59, Shakib 2-26, Rubel 1-62, Taijul 1-44, Mahmudullah 0-22)
Result: Bangladesh won by seven runs
Man of the Match: Shakib Al Hasan (Bangladesh)