Dhoni and Dinesh Karthick (58 not out) put on a match-winning stand of 107 for the sixth wicket as the tourists, reduced to 144-5 chasing Bangladesh's 250-7, recovered to win with six balls to spare.
It was India's first match since their humiliating first-round exit in the World Cup where they lost to Bangladesh in their opening game and also succumbed to eventual finalists Sri Lanka.
Bangladesh's total was built around opener Javed Omar's 80 and and a gutsy half-century from Saqibul Hasan, who also took two wickets with his left-arm spin.
Dhoni, who came in at number three, anchored the innings till the end and was supported by Karthick to turn a near-defeat into a morale-boosting win.
But the stifling 38 degrees Celsius (100 Fahrenheit) heat, combined with 90 percent humidity, caused Dhoni leg cramps midway through his innings and Yuvraj Singh ran for the hobbling batsman.
A sell-out crowd of 28,000 at the Sher-e-Bangla National Stadium braved the oppressive heat to cheer the hosts in a match reduced to 47 overs a side after a drizzle delayed the start by 50 minutes.
India got off to a rollicking start, posting 56 by the seventh over for the loss of openers Virender Sehwag and Gautam Gambhir.
Sehwag hit 30 off 21 balls and Delhi team-mate Gambhir made 21 before both fell to left-arm spinner Syed Rasel.
Bangladesh, depleted by the absence of pace spearhead Mashrafe Mortaza due to a back strain, dismissed Yuvraj, captain Rahul Dravid and Dinesh Mongia cheaply to reduce India to 144-5.
But Dhoni, later named the man of the match, and Karthick, kept their cool in the heat to guide India home.
Bangladesh, who earned their best ever finish of seventh place in the World Cup, did not disappoint their fans after choosing to take first strike.
Omar and Tamim Iqbal put on 78 for the first wicket before India hit back with two wickets in the space of four deliveries.
Omar and Saqibul attacked the Indian bowlers on the slow wicket to put on 107 for the third wicket.
Omar hit seven boundaries and two sixes - one each off Ramesh Powar and Mongia - before he was run out by a direct throw from Zaheer Khan while attempting a second run in the 39th over.
Saqibul departed two overs later for a stroke-filled 50 when he was stumped off Mongia to make Bangladesh 200-4.
Mongia finished with 3-49 and Powar took 2-55, but seamer Zaheer Khan was hammered for 54 runs in his seven overs.
The second match will be played here on Saturday, followed by the third in the port city of Chittagong on May 15.
India will also play two Tests at Chittagong (May 18-22) and Dhaka (May 25-29).