Bangladesh opener Imrul Kayes hit an unbeaten half-century as the hosts took a lead of 128 with seven second-innings wickets remaining against England on the second day of the second and final Test in Dhaka, on Saturday.
Kayes was on 59 as the hosts reached 152 for three in their second innings at stumps.
Mahmudullah was bowled out to debutant spinner Zafar Ansari (2-33) on the last ball of another eventful day at the Shere Bangla National Stadium after adding 86 for the third wicket with Kayes.
Bangladesh got a brisk start from first-innings centurion Tamim Iqbal, who hit a 47-ball 40, and Kayes who put on 65 for the opening partnership before the former became Ansari's first Test wicket.
Earlier, Bangladesh off-spinner Mehedi Hasan picked up his second five-wicket haul of the series but a ninth-wicket stand of 99 gave England a first innings lead of 24.
England, who lead the series 1-0 and resumed on 50-3, were reduced to 144 for eight in the first session but the partnership between Chris Woakes and Adil Rashid put paid to Bangladeshi hopes of a first-innings lead.
The second new ball finally bore fruit for the hosts as 19-year-old Mehedi (6-82) dismissed Woakes for 46 to break the dogged stand.
Left-armer Taijul Islam (3-65) took his third wicket in the following over to dismiss England for 244 and bring up tea on the second day, leaving Rashid 44 not out.
Thirteen wickets had fallen on the opening day and it did not take long on Saturday for Mehedi, who also picked up six wickets in Chittagong on debut, to send back Moeen Ali for 10 and Ben Stokes to fall for a duck off a bat-pad catch.
That left England struggling at 69 for five and the tourists were grateful to Joe Root and Jonny Bairstow for digging them out of a hole with a 45-run stand for the sixth wicket.
Bangladesh captain Mushfiqur Rahim turned to Mehedi to break the partnership and the youngster duly delivered, dismissing Bairstow leg before for 24 with the first delivery of his spell.
Root, who was dropped on 19 at slip off Taijul, showed great determination and nimble footwork to bring up his 23rd half-century in Tests and built another stand with debutant Zafar Ansari before the latter became Mehedi's fifth victim for 13.
Taijul finally picked up the big wicket of Root for 56 with a leg before after the batsman misjudged the length and was hit on the back foot off a straight delivery.
Taijul thought he had his third when Woakes was given out caught behind but the batsman successfully reviewed to overturn the umpire's decision with replays confirming there was no edge.
Woakes was also caught on 38 off a high, full toss from part-time leg-spinner Sabbir Rahman but the delivery was adjudged to be above waist height by the television umpire.