Derbyshire boosted their chances of avoiding the drop with a 56-run victory that dented Middlesex's title hopes in Division One of the LV= County Championship.
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 Ollie Rayner’s unebaten 46, they were bowled out for 240.
Mark Footitt took 4-65 and off-spinner Peter Burgoyne 3-66 to give Derbyshire a second successive triumph.
Middlesex had successfully chased 327 in the fourth innings at Derby two years ago but their chances of victory today 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 never looked secure and played on aiming a firm-footed drive at the fast bowler, reducing Middlesex to 83 for four.
Derbyshire’s position improved further when visiting skipper Neil Dexter was bowled in the same over by one that cut back.
Voges fell soon after, edging Burgoyne to slip after two hours at the crease.
At 101 for six, 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; his stunned reaction as he stood at the crease while the other players headed for the pavilion summed up Middlesex's morning.
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 steering Matt Higginbottom to slip.
Toby Roland-Jones held up Derbyshire for another 10 overs, but was then caught down the leg side off Footitt before Burgoyne sparked wild celebrations by having Tim Murtagh held at slip.