All-rounder Chris Greaves was the star with bat and ball as he top-scored with 45 off 28 balls in Scotland’s 140 for nine, before taking two crucial wickets.
“We were in a tough situation obviously,” Greaves told Sky Sports. “It was a just (a case of) re-building the innings at that stage and see where we could go from there.
“It was unbelievable that I could be that person, to be a part of that is incredible.
“It was my day I think. There will be many other days when any one of us in that squad can be a part of it. I’m just so glad I could contribute what I did.”
Put in to bat, Scotland were reeling at 53 for six in the 12th over before Greaves added 51 runs with Mark Watt, who struck 22 off 17 balls, to post a respectable total which proved enough to earn them a shock result.
Bangladesh, fresh from T20 wins over Australia and New Zealand, went into the game as favourites to win the qualifying group and it looked to be going their way when Scotland lost their captain Kyle Coetzer for a duck in the third over, bowled by Mohammad Saifuddin.
George Munsey, who struck two sixes in his 29, and Matthew Cross steadied the innings with a 40-run second-wicket partnership before both perished in an over from Mahedi Hasan.
Richie Berrington, whose century helped the Scots beat Bangladesh in their only previous meeting, fell cheaply when he was caught at long-on off Shakib Al Hasan, who also removed Michael Leask for a duck.
Greaves then came to the rescue, hitting two sixes and four fours in his 28-ball knock to bring Scotland back into the contest.
Earlier, Bangladesh’s Shakib Al Hasan became the highest wicket-taker in men’s T20Is, overtaking Lasith Malinga’s total of 107 wickets.
The left-arm spin-bowling all-rounder is the first player in T20Is to score 1,000 runs and take 100 wickets and he was just starting to get into his flow with the bat when he became Greaves’ first victim.
Greaves then removed the dangerous Mushfiqur Rahim for 38 and finished with two for 19 while Brad Wheal claimed three for 24.
Needing 24 off the last over, Saifuddin and Mahedi combined for two fours and a six off Safyaan Sharif but were unable to get their side over the line.
The result hugely boosts Scotland’s chances of reaching the main Super 12 stage of the tournament, for which eight teams, including the likes of England, India and Australia, have already qualified.
Scotland will also play Oman and Papua New Guinea in their qualifying group, with the top two teams advancing.
Additional reporting by PA.