Australia, chasing 307 to win, were 212 for four at the close of the fourth day of the first Test against Bangladesh on Wednesday.
After dominating the first two days, the hosts crumbled to 148 all out in their second innings after resuming at 124 for five.
Half centuries by Matthew Hayden (72) and skipper Ricky Ponting guided Australia towards victory before three late wickets gave Bangladesh renewed hope of an extraordinary win.
Ponting and Adam Gilchrist, a century-maker in the first innings, were not out on 72 and 6 respectively.
Bangladesh scored 427 in their first innings. A brilliant 144 by Adam Gilchrist helped Australia recover to 269 in reply and their bowlers returned to form to rip through the Bangladesh batting in the hosts' second knock.
Bangladesh lost their two previous Tests against Australia in 2003 by an innings. They have won only one of their 42 Tests since 2000, that victory coming over a depleted Zimbabwe side.