Derbyshire had an excellent chance of celebrating back-to-back victories after they took two early wickets as Middlesex chased 297 to win the LV= County Championship Division One match at Derby.
Middlesex lost Joe Denly and nightwatchman Steven Finn - who was out twice in the day without scoring - to close on 25 for two after Ollie Rayner took 5-67 to dismiss Derbyshire for 160.
Rayner had scored his first championship half-century of the season before the title-contenders were bowled out for 249, with Mark Footitt taking his 100th first-class wicket to finish with 3-69.
Middlesex's first objective was to reach the follow-on target of 236 but they lost John Simpson with 28 still needed when he was beaten by Shivnarine Chanderpaul's direct hit from midwicket.
When Toby Roland-Jones drove at a wide delivery from Tim Groenewald and edged to third slip, the visitors were 224 for eight.
However, Rayner drove Footitt through the covers to remove the threat of the follow-on and went on to complete a 108-ball fifty.
Footitt wrapped the innings up in the next over when Tim Murtagh was caught behind and Finn was lbw second ball.
Derbyshire had a healthy lead of 136 but they were soon in trouble as Murtagh and Finn reduced them to 16 for three, with Ben Slater, Wayne Madsen and Chesney Hughes all dismissed before lunch.
Derbyshire could have been thinking back to their 60 all out at Lord’s in April, but Chanderpaul and Richard Johnson restored some order by adding 52 in 17 overs.
Chanderpaul drove Rayner for six but the West Indies Test star was soon lbw for 32 playing across the line at Roland-Jones.
Johnson's well paced innings ended when he was caught off bat and pad for 59 and Rayner profited from Derbyshire's desire to push on with Tom Poynton and Footitt falling to catches in the deep.
Middlesex still faced a tough chase on a pitch starting to show signs of uneven bounce and they lost Joe Denly in the fourth over, lbw to a ball that kept low from Footitt, before Finn bagged a pair when he was leg before for the second time in five-and-a-half hours.
Derbyshire will hope Groenewald is fit to bowl on the final day after he left the field four overs before the close with an ankle problem.