Bangladesh 220 (Tamim 104, Moeen 5-57) and 296 (Imrul 78, Rashid 4-52) beat England 244 (Root 56, Mehedi 6-82) and 164 (Cook 59, Duckett 56, Mehedi 6-77, Shakib 4-49) by 108 runs
Scorecard and ball-by-ball details
Bangladesh claimed ten wickets in an electric final session to secure an historic first Test victory over England and a 1-1 share of the series. That it came after England's openers had put on a century stand was the final twist in a remarkable match and only heightened the sense of their achievement. The crowning moment was delivered by the teenager Mehedi Hasan, who finished with another six-wicket haul, 12 in the match and the best figures by a Bangladeshi to spark scenes of jubilation at Mirpur.
The result provided atonement after Bangladesh had gone so close in Chittagong, finally giving them a win over one of the major Test nations: in 94 matches previously they had only beaten West Indies and Zimbabwe. It also posed fresh questions for England, who went from 100 for 0 to 164 all out in 22.3 mesmeric overs as Mehedi and Shakib Al Hasan claimed all ten between them.
At tea, England had edged the equation back in their favour, knocking the requirement from 273 down to a seemingly more manageable 173 thanks to their best opening partnership of the tour. But from the very first delivery after the interval, Mehedi speared the ball into Ben Duckett's stumps and England's dream start became a waking nightmare against spin, a Halloween horror show in which every wicket was greeted with ghoulish glee by the Mirpur crowd.
Moments later Joe Root, already zombified by illness, stumbled from the field after a two-ball 1 and although Alastair Cook followed Duckett in reaching fifty, England were about to enter a death spiral. From 122 for 2, Bangladesh claimed 4 for 15 in 38 balls, England's middle-order guts ripped out as Mehedi completed a ten-wicket haul in only his second Test. After Duckett and Cook, only Ben Stokes managed double-figures.
Gary Ballance's tortured series ended with a misbegotten leading edge to mid-off and Moeen Ali was lbw to Mehedi in the same over but Bangladesh must have truly believed when Cook popped a catch to silly point - a superb take from Mominul Haque standing as close to the cut strip as he dared - to leave England five down. The sense of grievance Bangladesh apparently felt after Cook had overturned an lbw decision off Mehedi a few overs before, Hawk-Eye projecting the ball to be missing leg stump, was immediately forgotten.
From that point, the ending was inevitable - it was merely a question of when. Jonny Bairstow became Mehedi's 11th victim when an inside edge ballooned to leg slip and although Stokes attempted to hold back the tide, smiting Mehedi for a towering, defiant six, he was bowled playing inside the line of a delivery from Shakib, who claimed three in four balls to put Bangladesh on the brink of a victory that had repeatedly threatened to squirm from their grasp.
Few could have foreseen quite such a dramatic finish at the start of the day. Having been well placed on 152 for 3 overnight, Bangladesh's batsmen resolved to play positively and they succeeded in almost doubling their score. Stokes and Adil Rashid claimed six of the seven wickets to fall, keeping the target below 300, but 273 was still significantly more than England had previously achieved in Asia - coincidentally their 2010 pursuit of 209 at Mirpur, which was also the record on the ground.
They were given the perfect start, however. Cook and his latest partner had a previous best of 26 together and, given England's propensity to go from one to three down (or, in this case, all out) in short order, it was a timely improvement. Duckett's penchant for the reverse-sweep was well known in domestic circles but he unwrapped it for the citizens of Dhaka in the fourth over of the innings, striking back-to-back boundaries off Shakib.
There were one or two misjudgements, a top edge from a cut bursting through the hands of slip, while Kamrul Islam Rabbi could not get his hands under a wild slice running in from cover, but living dangerously was at least living. Duckett went to his maiden Test fifty, from just 61 deliveries, with a swept four and he brought up the hundred with a fierce pull of Mehedi's next ball to further quieten a nervous crowd - at least until the resumption after tea.
A chaotic morning session had seen four wickets, as many catches go down, a couple of reviews wasted and 116 runs added to the Bangladesh total. No batsman was able to survive for long but they successfully staved off the outright collapse England had hoped for, as tempers began to fray.
Stokes was at the centre of trying to lift England but his approach seemed to draw comment from the umpires, who approached Cook to try and calm things down. Stokes was unhappy at Sabbir Rahman advancing down the pitch during a brisk seventh-wicket partnership that repelled England once again and frustrations mounted after they lost their second review seeking a caught-behind decision against Bangladesh's No. 7, who was eventually lbw to Rashid from the last ball before lunch.
England created chances from the outset but Bangladesh's batsmen kept pushing the scoreboard on. Imrul Kayes swept and nudged while the more adventurous Shakib rode his luck to add 48 together inside the first hour and although the wickets did eventually come, England's hopes of running through the middle- and lower-order for a second time in the match were stilled.
Imrul had two let-offs before finally falling for 78. In the sixth over of the morning, on 67, a leg-side flick off Zafar Ansari went quickly to the right of Cook at leg slip and the England captain could only palm it away; then on 74, a simpler chance off the bowling of Moeen was put down by Root, going one-handed to his right at slip.
The Bangladesh opener fell shortly after, lbw to Moeen attempting to sweep, and Shakib might have been stumped in the following over, charging at Ansari, only for the ball to explode off the pitch and clear Bairstow's right shoulder. Ansari should certainly have had Shakib's wicket on 23 when a slog-sweep picked out Duckett at deep midwicket but he made a complete hash of the catch and the same bowler then saw Mushfiqur survive a mistimed chip to Steven Finn running back at mid-off.
England's use of technology was also erratic, failing with one DRS attempt against Mushfiqur - Ansari's delivery pitching outside leg - but opting not to review a pair of lbw appeals from Moeen's bowling, once each against Shakib and Mushfiqur, that would likely have been overturned.
Shakib's innings was cut short on 41 as Rashid ripped a legbreak in from round the wicket and Stokes had Mushfiqur taken at slip in the following over but by then the lead was above 200 and England's task on a surface that continued to assist spin bowling was looking a daunting one. This time, Bangladesh would not let them off the hook.
Alan Gardner is an assistant editor at ESPNcricinfo. @alanroderick