Middlesex 297 (Simpson 92, Eskinazi 64, Higgins 53, Finan 5-58) and 271 (Holden 91, Stoneman 81, Parkinson 4-69) beat Leicestershire 294 (Swindells 67, Scriven 65) and 194 (Ackermann 80, Roland-Jones 4-50) by 80 runs
Having had Leicestershire on the ropes at 13 for four at Thursday's close, Middlesex took rather longer than anticipated to finish the job, but duly completed an 80-run victory to set up an unexpectedly exciting finale to the Division Two campaign in the LV= Insurance County Championship, with still three contenders for the two promotion places.
Toby Roland-Jones finished with four for 50 and seven wickets in the match as Leicestershire were bowled out for 194, Colin Ackermann mounting the most significant show of resistance, batting almost four hours for his 80.
Tailenders Chris Wright and Michael Finan had some fun at the end, thrashing 61 runs in just over 11 overs for the final wicket.
Nottinghamshire had looked to have the Division Two title in the bag after seven wins, but after their humbling defeat by Worcestershire at New Road earlier this week, Middlesex's victory makes a substantial hole in their cushion at the top of the table.
It means the leaders will begin the last round of fixtures on Monday with their advantage cut to just nine points, with Middlesex in second place, although themselves looking nervously over their shoulders at Glamorgan, whose win against Derbyshire in Cardiff puts them only nine points further back in third spot.
Nottinghamshire's final opponents are Durham at Trent Bridge, while Middlesex themselves travel to Worcester. Glamorgan take on Sussex at Hove.
Leicestershire might have been in further disarray on the third evening had bad light not allowed them to return to the haven of the dressing room earlier than scheduled.
They lasted just over half an hour on the final morning before losing their fifth wicket, Harry Swindells walking even before the umpire's finger was raised after a swinging delivery from Roland-Jones hit him squarely in front.
Tom Scriven, the former England Under-19s all-rounder, played nicely alongside Ackermann as the pair added 34 for the sixth wicket, but the introduction of Luke Hollman's leg spin brought an immediate dividend, as it had twice previously in the match.
Scriven was his victim this time, popping up a bat-pad catch to short leg as he sought to flick one away. When Barnes fell without scoring, beaten for pace when lbw to Ethan Bamber, Leicestershire were 70 for seven.
Yet with the obdurate Callum Parkinson now at the other end, Middlesex were frustrated for more than an hour and a half before they could claim the eighth wicket, Leicestershire adding 65 runs in the process, with Ackermann surviving a chance to wicketkeeper John Simpson on 51.
The breakthrough came via an unexpected route. Sam Robson succeeded where Hollman had been unable to make further inroads, the off-spinner deploying a leg break to have Ackermann leg before on the sweep.
One wicket brought another as Parkinson fell in the next over, Tim Murtagh pushing one through to hit the front pad in line.
Yet Middlesex were made to wait for a little longer before their celebrations could begin, Wright and Finan taking the opportunity to swing the bat under no pressure, the former finishing 36 not out after Finan holed out to deep midwicket off Robson to end the contest at 3.15pm.
Leicestershire, deeply rooted at the bottom of the table, have one more chance - away to Derbyshire - to avoid another full season without a Championship win, a fate that befell them three times in the last decade.