England reached 50 for one at the end of the powerplay but losing three wickets in 16 balls sucked the momentum out of their innings and Mehidy claimed four for 12 as the tourists were all out for 117.
At the same venue where the off-spinner took 12 wickets to lift Bangladesh to a first Test victory over England in 2016, Mehidy then contributed a vital 20 off 16 balls in a nail-biting chase.
Jofra Archer cranked up the pace and collected three for 13 to leave 13 needed off 12 balls but Chris Jordan was dispatched for three fours after being asked to bowl the penultimate over – his first.
Ultimately England's downfall came down to a dismal batting display after rejigging their top-order, with Phil Salt and Dawid Malan opening, Moeen Ali at three and captain Jos Buttler at four in an attempt to redress some balance following their six-wicket defeat in Chattogram on Thursday.
Ben Duckett top-scored with a run-a-ball 28, having to rebuild after the cluster of wickets, while Salt registered a punchy 25 off 19, as five of their batters were out for single-figure scores.
Rehan Ahmed, England's youngest men's Test and ODI cricketer, became his nation's first male teenage player in the shortest format, claiming one for 11 in two overs but his day ended on a losing note.
England were asked to bat first after Buttler lost the toss for the eighth time in a row and they accelerated following the early loss of Malan to get into a handsome position after the powerplay.
Neither Salt nor Moeen were especially convincing as they both edged just out the reach of slip but the pair also collected a six apiece.
Boundaries after the sixth over were a rarity, though, as England's top-order disintegrated. Salt's habit of backing away to open up the offside was his undoing as he miscued a return catch to Shakib Al Hasan while Buttler was castled by a special yorker from Hasan Mahmud and Moeen holed out off Mehidy.
Duckett and Sam Curran rebuilt, allowing Bangladesh to slip in an over each from part-time off-spinners Najmul Hossain Shanto and Afif Hossain to the left-handers with minimal damage before Mehidy's return.
The frontline off-spinner saw Curran advancing and adjusted his line and length before Litton Das whipped off the bails while Chris Woakes fell in identical fashion two balls later – although he was undone by some sharp spin through the gate.
Mehidy had his fourth when Jordan heaved across the line to deep midwicket and although Ahmed took fours off Mustafizur Rahman and Shakib in a run-a-ball 11, it was mere window dressing as England lost three wickets in the last over.
Curran drew the edge of Rony Talukdar, only for the ball to scuttle away as Bangladesh took 15 in the first two overs of the chase but the left-arm seamer was in clover when Litton pulled uncertainly to Salt.
England's short-ball ploy reaped further rewards when Rony clothed to mid-on off Archer and while Najmul was able to get a four away off the quick, he was largely becalmed before Towhid Hridoy released some of the building pressure with a couple of drives.
Ahmed struck with his second ball, a short and wider ball tempting Towhid to slap to Chris Woakes but Mehidy put Bangladesh back into the driving seat with sixes off spinners Rashid and Moeen.
There was pin-drop silence among the packed-out crowd when Mehidy then miscued a pull off Archer, whose searing 92mph delivery took out Afif Hossain's off-stump after Shakib had hacked Moeen to long-off.
Buttler did not turn to Jordan until the 19th over and his first ball, a slower delivery down the leg-side was put away by Najmul, who, fresh from his 27-ball fifty in the opener, anchored proceedings here with an unbeaten 46.
A misfield from Ahmed allowed Najmul to sneak in another couple before he deferred to Taskin Ahmed, who took successive off-side fours off Jordan as Bangladesh won with seven balls to spare to leave only pride to play for in the final match of the series on Tuesday.