Opener Imrul Kayes hit 59 not out as Bangladesh reached 152-3 Saturday, gaining a useful 128-run lead against England at stumps on the second day of the second test.
Fellow opener Tamim Iqbal struck a fluent 40 before England made inroads with two quick wickets, leaving Bangladesh on 66-2.
Kayes and Mahmudullah combined for 86 runs and appeared to take firm control. But Mahmudullah played a reckless shot against the last ball of the day to be dismissed for 47.
Zafar Ansari took 2-33 on his England test debut.
Earlier, Chris Woakes and Adil Rashid combined for 99 runs as England was all out for 244 in its first innings, taking a 24-run lead after Bangladesh's 220.
"I think it's evenly balanced, I think us getting a lead was quite crucial," Woakes said. "We're really pleased from that point of view. It would have been nice to have got a couple more wickets tonight and maybe for less runs but it is what it is and that wicket at the end probably gives us a little bit of confidence going into tomorrow."
Mehedi Hasan claimed 6-82 for Bangladesh, his second six-for in as many tests. "Hopefully our batsmen put a good total on the board and then we spinners are able to do the rest," Mehedi said.
Bangladesh made a fluent start to its second innings, courtesy of Tamim Iqbal (40 off 47 balls) who showed sustained aggression before being caught at leg slip by Alastair Cook as Ansari's maiden wicket brought an end to the 65-run partnership.
Two balls later, Ben Stokes got Mominul Haque for 1 with a short delivery, leaving Bangladesh on 66-2.
Kayes and Mahmudullah stalled England's sudden charge, using their feet well against the spinners. They appeared to be taking control of the test before Mahmudullah's dismissal ended the day for Bangladesh in disappointing fashion.
Rashid and Woakes had survived some anxious moments to earn an important lead for England, which at one point was 76 runs behind with only two wickets left. Woakes won a video review on 2 and survived a dismissal on a no-ball off Sabbir Rahman on 38. They put on England's highest ninth-wicket partnership in Asia, eclipsing 83 runs by Norman Gifford and Keith Fletcher against India in 1973.
Offspinner Mehedi Hasan broke the stubborn partnership when he found the edge of Woakes for 46 with the new ball.
left-arm spinner Taijul (3-35) then got Steven Finn to wrap up the innings and prompt an early tea.
Rashid was unbeaten on 44.