England batted first and put 309-8 on the board from their 50 overs. The main contributors for the visitors were Ben Stokes, who made 101, Ben Duckett, striking 60 on his debut and Jos Buttler's quickfire 63 at the end.
In reply, the hosts were strolling to victory at 271-4 but they collapsed, losing six wickets for 17 runs to hand the game to the tourists. Imrul Kayes, 112, and Shakib Al Hasan, 79, will both be bitterly disappointed their runs didn't lead to victory.
Both teams will meet again in Dhaka on Sunday with Bangladesh looking to avenge this defeat when they should have won.
England won the toss and chose to bat first
Buttler, captaining England for the first time, won the toss and chose to bat first in very warm conditions. Duckett and Jake Ball came into the team to make their ODI debuts.
The tourists' new opening partnership of James Vince and Jason Roy got off to a positive start as they reached 41 when Vince fell for 16 (20) going for a big shot off the bowling of Shafiul Islam.
That brought Duckett to the crease to join Roy on his debut as he looked to impress. Roy was looking in fine form before he was caught on the boundary for 41 (40) trying to hit a six of the bowling of the impressive Shakib.
The hosts took three early wickets
It got worse for the tourists soon after as they lost Jonny Bairstow for a duck when he was run out by Sabbir Rahman going for a quick single, to leave the tourists teetering on 61-3.
It meant that Ben Stokes came to the crease to join Duckett as the pair looked to put on a big partnership.
Stokes and Duckett lead fightback with partnership of 153
They did just that as both went to their half-centuries in their partnership of 153. Duckett was the one to fall for a well made 60 (78) off the bowling of Shafiul to bring to an end an eye-catching debut innings.
Stokes was well set and continued on his merry way as he brought up his century. The left-hander though fell not long after that for 101to Mashrafe Mortaza.
Moen Ali fell soon after for six as the hosts looked to restrict the tourists. The problem though was that Buttler was at the crease and he started taking the attack to bowlers as smashed his way to another half-century.
Buttler's quickfire half-century took the visitors past 300
Alongside Chris Woakes the pair put on 63 before Buttler fell in the final over of the innings for 63 (38).
Woakes was also out run out of the last ball of the innings as the tourists posted a really good score of 309-8 on what was a tough pitch to score freely on.
Strong run chase from the hosts
In reply, the hosts got off to a solid start as Tamim Iqbal and Kayes went about setting up a solid foundation. Their partnership reached 46 when Ball made the breakthrough getting the wicket of Tamim for 17.
This brought Sabbir to the crease and from the off he went about scoring runs quickly. It was working well until a brilliant catch from David Willey on the boundary ended his innings off the bowling of Ball on 18 (11).
Kayes though, now joined at the crease by Mahmudullah, continued his great form from the warm-up game against England by going past his half-century.
At the other end, Mahmudullah wasn't doing that bad either as the pair took their partnership past fifty and threatened to take the game away from England.
This was until Adil Rashid got the wicket of Mahmudullah for 25 when he went for one big shot too many to give England a crucial breakthrough. It didn't take long for Rashid to get another wicket as Mushfiqur Rahim was next to go for 12 trying once again to hit Rashid out of the park.
The wicket brought the experienced Shakib to the crease and himself and Kayes went about building a strong partnership.
Kayes, struggling with cramp, went to his second ODI century during the partnership with four overthrows from Willey.
At the other end, Shakib also brought up his half-century as the pair took their partnership past the century mark.
Hosts collapse to hand the visitors the win
Just as it looked like the hosts were going to get the win at a canter, three wickets fell for three runs.
Ball was the main culprit as he firstly dismissed the dangerous Shakib for 79 (55) before bowling Mosaddek Hossain for a duck next ball to claim his fourth wicket of the innings.
Rashid then in the next over got his third wicket, removing the Mortaza for one to really put the game in the balance.
It swung even more in England's favour when Rashid got the big wicket of Kayes for 112 stumped by Buttler.
The hosts continued their massive collapse as Shafiul was run out for a duck and then Taskin Ahmed was out for one off the bowling of Ball, who took five wickets on his debut to win his country the match by 21 runs.