Ben Stokes performed third-day heroics to put England in a strong position in the first Test after Bangladesh threatened to plunge the tourists into the mire in Chittagong.
Stokes took three wickets in the morning session to finish with figures of 4-26 as the Tigers were bowled out for 248, giving England a lead of 45 at Zahur Ahmed Chowdhury Stadium.
Shakib Al Hasan (5-79) wrestled Bangladesh back into a promising position, with England reduced to 62-5 in the afternoon session, but Stokes (85) and Jonny Bairstow (47) turned the tide with a potentially match-winning stand of 127 for the sixth wicket.
The combative Stokes fell short of a deserved fourth Test century on a difficult surface as Bangladesh took three wickets in the final session to leave England 228-8 with an advantage of 273 runs at stumps on another compelling day.
Bairstow passed Andy Flower's record mark of 1,045 Test runs by a wicketkeeper in a calendar year as he combined with Stokes for what could prove to be decisive union.
Shakib aimed to set the tone with the bat when he gave Moeen Ali (3-75) the charge, but missed what was only the second delivery of the day and was stumped after the Tigers resumed on 221-5.
Stokes took centre stage after Adil Rashid (2-58) got rid of Shafiul Islam for two, generating swing and movement off the seam in a brilliant spell to wrap up the Bangladesh innings.
Mehedi Hasan (1) was trapped leg before from a Stokes delivery which swung back in sharply before Sabbir Rahman (19) and Kamrul Islam Rabbi (0) went in the same over.
England were reeling on 28-3 at lunch after Shakib struck twice, with captain Alastair Cook (12), debutant Ben Duckett (15) and Joe Root (1) failing.
The procession of wickets continued as Taijul Islam (1-40) dismissed Gary Balance for nine - possibly his last innings of the series - and Moeen (16) missed out after being given a reprieve when he was caught at short leg but the ball struck Mominul Haque on the helmet.
Stokes and Bairstow steadied the ship, with the left-hander showing great discipline to rein in his customary attacking style before raising the tempo after tea, hitting Tajul for a huge six over midwicket.
Bairstow was composed in testing conditions, picked off loose deliveries and rotating the strike well, and Stokes had a stroke of luck when he picked up five runs after he swept Shakib behind into a helmet.
Stokes brought up his half-century in style by launching Tajul for another big six and cleared the ropes for a third time as Bangladesh's frustration mounted.
Bairstow became Rabbi's first Test victim when he played on and Stokes' superb 151-ball knock was ended by Shakib, who had a 15th five-wicket haul in Tests when Rashid was given out leg before following a review.
Chris Woakes and Stuart Broad were unbeaten on 11 and 10 respectively at stumps on another eventful day.