Afghanistan were reduced to 20 for 4 in the run chase, eventually folding up for 94.
Batters, with the exception of Litton Das, let Bangladesh down as they are bowled out for 192.
Liton made 136 while Rahim got 86 as the hosts posted 306, beat Afghanistan by 88 runs.
After being reduced to 45/6, Afif Hossain and Mehidy Hasan shared a record partnership to guide their side to a dream victory over Afghanistan.