All-rounder Shakib Al Hasan took five wickets for 85 runs to help the hosts bowl out Australia for 244 shortly into the second session on the fourth day.
David Warner top scored with 112 for the tourists, who were chasing a target of 265 after bowling out Bangladesh for 221 in the second innings.
Shakib lived up to his billing as the world’s number-one Test all-rounder, finishing with a match haul of 10 wickets and making 84 in Bangladesh´s first-innings total of 260.
Australia appeared to be coasting towards their fifth consecutive Test win against Bangladesh when Warner and Smith resumed the day on 109 for two.
But left-arm spinner Shakib brought Bangladesh back into the game, dismissing both Warner and Smith (37) to put pressure on the former number-one Test side.
Australia are currently ranked fourth to Bangladesh’s lowly ninth.
Shakib´s spin partner Taijul Islam chipped in with three wickets to cap a memorable day for the side dubbed the Tigers.
Pat Cummins hit a valiant 33 not out with three fours and two sixes in a late charge but failed to stop the inevitable.
The second Test will be held in Chittagong from September 4-8.