Bangladesh lost their last five wickets for 16 runs to hand Zimbabwe victory in the third one-day international and the five-match series.
The visitors were well on the way to reaching their target of 251 with Mushfiqur Rahim seemingly in control of matters.
They required 22 off the last 19 balls when Mahmadullah was caught in the deep, sparking a dramatic collapse.
Chris Mpofu had Nasir Hossain caught two balls later before Kyle Jarvis bowled both Shafiul Islam and Rubel Hossain in the penultimate over.
Rahim watched in disbelief at the other end before reaching his century, but could still have saved the day with only six more required from the last five balls, but holed out to Vusi Sibanda at long-on off Mpofu for 101 to spark wild celebrations.
Earlier, Hamilton Masakadza and Tatenda Taibu hit half centuries, sharing in a third wicket partnership of 142, as Zimbabwe made 250-7 in their 50 overs.
The tourists got an early breakthrough when skipper Brendan Taylor edged an innocuous delivery from Shafiul straight to slip for four.
Fellow opener Sibanda (27) looked sharp but was caught out by a short ball from Rubel Hossain, pulling to Imrul Kayes.
Masakadza (74) and Taibu (83) then built a strong partnership before the former was cleaned bowled by Rubel, who was also involved in Taibu's dismissal as he held onto a catch off the bowling of Nazmul Hossain.
Of the tail, only Elton Chigumbura (31) added any runs of note to the Zimbabwe total, which was getable on a good wicket.
Bangladesh made a sluggish start to their run chase as Prosper Utseya removed Kayes and Junaid Siddique cheaply before Tamim Iqbal (44) was run out while trying to push for a second.
Mushfiqur then took centre stage, smashing eight fours and a six on his way to maiden ODI century. But he was losing partners at a constant rate with only Shuvagoto Hom (32) offering any sort of support before he went the same way as Tamim.
The quick scoring of Mushfiqur meant the visitors had the chance to win the match and keep the series alive as they entered the final over requiring eight runs to win with only one wicket remaining.
But the centurion tried one big shot too many and played a short ball from Mpofu straight into the hands of Sibanda at long-on from the second ball as Zimbabwe secured a memorable five-run win.