Ponting was batting on 72 at stumps on the fourth day with first-innings centurion Adam Gilchrist on six as Australia reached 212-4, 95 short of a win.
The tourists lost three wickets towards the end of the day's play after Hayden (72) had ensured a steady start but Ponting was immovable.
His innings has so far lasted 169 balls, during which he hit seven fours.
Despite conceding a shock 158-run first innings lead, the Aussies showed the mettle of the world's top team. They struck back by dismissing the home side for a meagre second-innings 148 and then batted sensibly in their final innings.
Hayden played a vital role, adding 64 with the other left-hander Michael Hussey (37) and then figuring in a crucial 111-run stand with Ponting.
He struck eight fours and a straight six off left-arm spinner Mohammad Rafique during his 152-ball knock and also went for some quick singles in a bid to keep the pressure on the fielders.
In the end, it was one such single to mid-on that ended Hayden's innings as Enamul Haque made a direct throw to the bowler's end.
Ponting continued to graft for his runs even as Damien Martyn (seven) and Michael Clarke (nine) went cheaply against a probing bowling attack led by Rafique, who got both scalps.
Australia, who have won both their previous Tests against Bangladesh by innings margins, had bounced back from their first innings deficit to reduce Bangladesh to 124-5 on the third day.
Shane Warne and Jason Gillespie dismissed the remaining batsmen for just 24 runs on Wednesday morning.
Paceman Gillespie struck the first blow when Khaled Mashud (zero) was bowled offering no stroke to a ball that nipped back sharply.
Gillespie also dismissed the other overnight batsman Rajin Saleh (33) before leg-spinner Warne grabbed three quick scalps after going wicketless in the match so far.
"I am not bowling as well as I would like to, but it was satisfying to help the team in a tricky situation," said Gillespie.
"The match is not yet over and one should give full credit to the Bangladeshi players for putting up such a stiff fight," he added.
Warne had revenge on Rafique, trapping the left-hander leg-before after being whacked for three fours in the previous over, and then bowled Mashrafe Mortaza with his next ball.
Last man Haque (zero) was also trapped leg-before by the world's leading wicket-taker as the home side lost the initiative with an all-too familiar second-innings collapse.
Warne and Gillespie finished with three wickets each, Gillespie conceding just two runs for his two wickets on Wednesday morning.