Australia have scrapped and fought their way towards parity in the face of a Bangladesh spin bombardment, but the hosts remain in command of the first Test at stumps on day two in Dhaka.
A 49-run ninth-wicket partnership between returning tweaker Ashton Agar (41 not out) and dogged tailender Pat Cummins (25) rescued the visitors after they lost their three most experienced batsmen 12 overs into their first innings.
Test newcomers Matthew Renshaw (45), Peter Handscomb (33) and Glenn Maxwell (23) all missed chances to put the visitors in command, with Bangladesh holding all the cards in the series opener and dreaming of an historic victory.
The Tigers went to stumps at 1-45 holding a lead of 88, with opener Tamim Iqbal (30 not out) and nightwatchman Taijul Islam (0) the unbeaten batsmen.
Having top-scored for the hosts in their first dig with a dazzling 84, Shakib Al Hasan was again the star on the second day of his 50th Test, claiming his 16th career five-wicket haul. It means the allrounder now has five-fers against every other Test-playing nation, a remarkable achievement considering this is the first time he has played against Australia in the longest format.
But it was Shakib's spin twin, teenage sensation Mehedi Hasan (3-62), who made the second day's initial and most important breakthrough.
Having struck tons in four of his last five Tests in Asia, Australia captain Steve Smith's dismissal in the third over of the morning – clean bowled after missing a sharp-turning Mehedi off-break – left Australia 4-33 after resuming at 3-18 and still 227 runs in arrears.
If nothing else, the visitors would have at least been pleased they didn't then fall in a heap as they'd done often on recent trips to the subcontinent following the fall of their captain, as Handscomb and Renshaw set about erasing what was still a 227-run deficit.
Quick single: Cummins fiery burst pushes Ashes case
As they had been the previous evening, spin duo Shakib and Mehedi were in their element in the morning session, spinning some sharply while others skidded straight on.
Handscomb has a reputation for being one of Australia's best players of spin and he forced a bowling change by sweeping Shakib for four three times in five balls.
Renshaw looked less certain on the sweep; he top-edged a full-blooded one, and was saved by his thigh when he attempted the lap and reverse variations of the shot. Yet, as he did India, the lanky left-hander found a way to get off the strike and punish the rare loosener.
Just as Australia looked to have wrestled back the ascendancy, the 69-run stand was cut short when Handscomb played back to Taijul – the third wheel on the Bangladeshi spin wagon – and was plumb lbw for 33.
Three overs later and just moments before lunch, Renshaw followed the Victorian when he edged the first ball of Shakib's new spell to a juggling Soumya Sarkar at slip.
As he did in India, Matthew Wade looked confident sweeping the slow bowlers but he became Australia's fourth lbw victim when he remained upright and Mehedi struck his front pad.
The wicketkeeper looked resigned to the fact he'd been trapped in front and set off towards the dressing room but Maxwell didn't appear so sure. Television replays later showed he would have been spared if he'd sent the decision upstairs.
It was the first misstep Australia has made with the DRS in this match; all four of their challenges have been successful, while all three of Bangladesh's have been in vain.
But Australia couldn't gain any traction and when Shakib deceived an advancing Maxwell and had him stumped, they were still 116 runs adrift.
Agar had announced himself to the cricketing world with a free-flowing Ashes cameo four years ago and those aggressive instincts should have seen him stumped his as well when he charged Shakib first ball and missed, only for 'keeper Mushfiqur Rahim to squander the chance.
A short time later, Shakib was once again left fuming as a skied hoick from Cummins was put down by Shafiul Islam at cover.
After those early ventures, Agar and Cummins knuckled down and largely shelved their attacking instincts – a six each aside, they largely soaked up balls and pressure against the spirited Bangladesh attack.
Crowd favourite Mustafizur Rahman (0-13 from eight overs) tried valiantly to find life in an unresponsive surface for the quicks, but spin was the main danger and the slow bowlers sent down more than 80 per cent of the overs.
Quick Single: Shakib joins legends with record five
Shakib completed his five-wicket feat in his milestone match when he had Cummins lbw and Josh Hazlewood caught at short-leg, leaving Australia 43 runs behind.
Given the previous evening's and the morning's early woes, the deficit was far from disastrous but having eked out 71 runs after the fall of their eighth wicket at less than 2.4 an over – a snail's pace in modern Test cricket – Bangladesh's relative ease in getting through to stumps just one wicket down was a worrying sign.
While Hazlewood and Maxwell had strong shouts against Tamim – the former for a caught-behind, the latter an lbw – Smith opted not to risk his perfect review record, with replays suggesting he'd done so wisely on both occasions.
Australia were boosted by a late brain fade from Tamim's opening partner Soumya Sarkar (15), who strangely attempted to belt Agar back over his head with only two overs remaining in the day. A back-pedalling Usman Khawaja nearly made a meal of it but clung onto the catch by his ankles on the fourth attempt.
And despite the late scalp of Soumya, Bangladesh pushed their lead towards triple-digits before stumps and Australia must now be asking how many they can realistically chase on a fast-deteriorating surface.
AUSTRALIA XI: Steve Smith (c), David Warner, Matthew Renshaw, Usman Khawaja, Peter Handscomb, Glenn Maxwell, Matthew Wade, Ashton Agar, Pat Cummins, Nathan Lyon, Josh Hazlewood
BANGLADESH XI: Tamim Iqbal, Soumya Sarkar, Imrul Kayes, Sabbir Rahman, Nasir Hossain, Shakib Al Hasan, Mushfiqur Rahim (c), Taijul Islam, Mehidy Hasan Miraz, Shafiul Islam, Mustafizur Rahman
Australia in Bangladesh 2017
Australia squad: Steve Smith (c), David Warner (vc), Ashton Agar, Jackson Bird, Hilton Cartwright, Pat Cummins, Peter Handscomb, Josh Hazlewood, Usman Khawaja, Nathan Lyon, Glenn Maxwell, Matthew Renshaw, Mitchell Swepson, Matthew Wade.
Bangladesh squad: Mushfiqur Rahim (c), Tamim Iqbal, Soumya Sarkar, Imrul Kayes, Shakib Al Hasan, Mehidy Hasan Miraz, Sabbir Rahman, Nasir Hossain, Liton Das, Taskin Ahmed, Shafiul Islam, Mustafizur Rahman, Taijul Islam, Mominul Haque.
22-23 August Tour match, washed out
27-31 August First Test, Dhaka
4-8 September Second Test, Chittagong