Set a target of 245 to win, Bangladesh were coasting to victory after the pair posted career best scores to put together 132 for the third wicket.
Aftab made 92 in just 77 balls Saturday and Rahim, playing the more passive role, hit 57 in 96.
With just 36 runs needed to win and seven wickets remaining the situation looked bleak for Zimbabwe.
But then things went wrong for the tourists as 209 for three became 209 for four with Rahim's dismissal, then 216 for five as Sakib fell, and 216 for six with Tushmar Imran gone first ball Saturday.
Soon after it became 238 for seven as Mortaza departed, but with Habibul Bashar still at the wicket.
The eighth wicket fell at 242 with the departure of Baisya leaving three to get with two wickets standing.
Bashar's freak run out left Bangladesh on 242 for nine leaving them with three runs off the last pair at the wicket.
Abdur Razzak and Shahadat Hossain were left to get the team home with Razzak slamming Elton Chigumbura for a straight four to secure the series win.
Zimbabwe's innings was well constructed after they lost Terrence Duffin and Vusi Sibanda with 22 on the scoreboard.
Sean Williams, with 51, and Chaminorwa Chibhabha, with 54, put on a 100 partnership, again for the third wicket. A glut of seven sixes later by Chigumbura sent Zimbabwe soaring to 244 for nine.
Victory ensured a 3-1 series win for Bangladesh.
Zimbabwe 244 for 8 in 50 overs (Chigumbura 77, Chibhabha 54, Sean Williams 51; M Mortaza 3 for 52, Abdur Razzaq 1 for 36, Saqibul 1 for 42) lost to Bangladesh 246 for 9 in 47.4 overs (Aftab Ahmed 92, Mushfiqur Rahim 57, Tamim Iqbal 30; Mpofu 3 for 52, ainsford 2 for 41, Ireland 2 for 53) by one wicket