Bangladesh held firm after a mid-innings collapse to chase down a victory target of 271 with five wickets to spare against New Zealand, who still won the tri-nations series.
The result saw the Tigers claim their first triumph over the Black Caps outside of Bangladesh and also served as a dose of revenge for last week's four-wicket loss against the same side.
Fittingly, Mahmudullah (46) struck the winning runs in a contest that saw him surpass 3,000 runs in one-day internationals, as Bangladesh enjoyed a pre-ICC Champions Trophy morale boost.
After the early loss of Luke Ronchi (2), New Zealand upped the run rate as captain Tom Latham (84) and Neil Broom (63) compiled a 133-run partnership.
But the pair fell within a few overs of each other, Nasir Hossain (2-47) the bowler claiming two key scalps.
Ross Taylor's 60 not out from 56 balls helped his side to what appeared a defendable total, but Bangladesh proved more than equal to the challenge.
They too lost an early wicket, with Soumya Sarkar departing third ball, before Tamim Iqbal and Sabbir Rahman contributed 65 runs apiece to another big-scoring second-wicket pairing.
Having lost both players within eight deliveries, Mosaddek Hossain (10) followed them back to pavilion in the 30th over and the match looked to be turning New Zealand's way.
However, Mushfiqur Rahim posted 45 not out at a run a ball, including three fours and a six, while Mahmudullah brought up his landmark before pulling the winning runs beyond the boundary rope with 10 deliveries to spare.