Derbyshire boosted their chances of avoiding the drop with a 56-run victory that dented Middlesex's Division One title hopes in the match at Derby.
The visitors went into the fourth day needing another 272 with eight wickets standing but despite a season's best 71 from Gareth Berg and an unbeaten 46 by Ollie Rayner, they were bowled out for 240.
Mark Footitt took 4-65 and off-spinner Peter Burgoyne 3-66 to give Derbyshire successive victories to lift their hopes of staying in Division One.
Middlesex had successfully chased 327 in the fourth innings at Derby two years ago but their chances of victory here depended heavily on the overnight pair of Sam Robson and Adam Voges.
The breezy, hazy conditions suggested there would be some swing for the bowlers but the third-wicket pair looked settled until the 13th over of the morning proved unlucky for Robson.
He and Voges had added 50 in 17 overs but Tim Groenewald, who had left the field the previous evening with an ankle problem, brought one back to bowl Robson for 29.
It was a good ball but the next wicket was down to a loose shot as Eoin Morgan went cheaply when Footitt returned for his second spell of the day at the City End.
Morgan had never looked secure and when he aimed a firm-footed drive at the fast bowler, he edged the ball into his stumps to reduce Middlesex to 83-4.
It got even better for Derbyshire when visiting skipper Neil Dexter was bowled in the same over for two by one that cut back, and they snared the big wicket of Voges five overs later.
The Australian had played well for two hours but when he pushed forward at Burgoyne, he got a low edge to slip where Chesney Hughes took a smart catch.
At 101-6, any hopes Middlesex had of victory were fading fast and it was now a case of how long they could delay Derbyshire.
The home side took a step closer to the finishing line when John Simpson scooped Burgoyne low to cover in the last over before lunch and his stunned reaction as he stood at the crease while the other players headed for the pavilion summed up Middlesex's morning.
At least Berg and Rayner made sure Middlesex did not go down without a fight as they combined watchful defence with controlled aggression to take the target under three figures.
Berg hit a six and 10 fours and added 85 in 24 overs with Rayner, before he steered Matt Higginbottom to slip but Toby Roland-Jones held up Derbyshire for another 10 overs.
He helped Rayner take the total to 236 but Footitt had him caught behind down the leg side and Burgoyne sparked wild celebrations when Tim Murtagh edged to slip three overs later.