Middlesex 247 (Gubbins 75, Ball 5-66) and 235 for 5 (Compton 63, Simpson 58*, Franklin 54*) beat Nottinghamshire 241 (Patel 100, Finn 4-54) and 240 (Mullaney 64, Rayner 4-83) by five wickets

The differing emotions between the two sides told the story: as the Middlesex dressing room reverberated with an exuberant rendition of the team song, Nottinghamshire's players sat looking tired and dejected.

Why? Because victory means Middlesex's title challenge remains alive and well. And defeat leaves Nottinghamshire relegated to Division Two for the first time in a decade.

A five-wicket margin may appear comfortable. And, it is true, in the last hour or so, as Nottinghamshire's head dropped, Middlesex ran away with this result.

But until then, until we had enjoyed 10 sessions of uncompromising, unpredictable, undulating cricket where the initiative passed between the sides almost as often as ball beat bat. It will be no consolation to Nottinghamshire, but this was a terrific game of cricket.

In a match of blow and counter blow, the defining punch was - arguably, at least - thrown by Nick Compton. Coming to the crease with his side under pressure, Compton negotiated some testing bowling and a demanding chase to break the back of the run-chase.

Gone was the stuttering, indeterminate Compton that we have seen at other times this summer and in his place was a man sure of his purpose and his method. He moved with certainty into his defensive strokes and, as he settled, used his feet to skip down the pitch and negate the threat offered by Imran Tahir with a series of fluent drives. It was, like elegantly sedate.

His tussle with Jake Ball was a compelling advert for county cricket. Ball, generating sharp pace and generally cutting the ball in, certainly didn't deserve to be on the losing side. Finishing the game with nine wickets - his team-mates claimed five between them - he looked a threat in every second-innings spell he bowled.

His first spell of the day - only three overs - did not concede a run, while his second produced the wicket of the increasingly fluent Stevie Eskinazi caught behind after following one outside off. Generally Compton, standing a long way over towards off stump and playing everything as if it would nip back, looked to see Ball off and pick-up runs against the other bowlers and it was noticeable that, as the ball aged, Ball gained less away movement from deliveries pitched on the stumps. Gradually, Compton took control and the target was whittled away.

Nottinghamshire's spinners were a little disappointing. Perhaps the slow nature of the surface did them few favours - they are not the first spinners to struggle here - but on a used pitch, more was expected of them in the fourth innings. Samit Patel, who batted so well in the first innings, did himself few favours in the fourth in front of the watching Andy Flower. You can understand the logic of England taking him to India, in particular, as third spinner but you wouldn't think Virat Kohli is having any sleepless night about the prospect. To be fair, he is probably not too worried about any of England's spin options.

"These are the moments when you want to be counted," Compton said afterwards. "As a senior player, it was my job to win us that game and I'm proud of the way I held the team together. I wanted to win this game for us.

"I felt under pressure this morning. I thought 'let this me my calling; let's get them over the line.' It feels great to have come back into the team and contributed.

"I've not been on it like that this season. But that was the real me out there. I decided I was just going to do it and I needed that focus here because Ball bowled really well, especially on the third evening."

It wouldn't have been Nick Compton though if he had finished with a raised bat and standing ovation. Instead, with the bulk of the job done (Middlesex required 89 when he was dismissed), he ran himself out after being sent back attempting an optimistic single. "I'm happy to do my job for the team and leave out of the back door without any fuss," Compton said.

"He has a technique as good as anyone in England," John Simpson agreed. "He is a fantastic batsman and he laid the foundations for us."

Simpson himself more than played his part. Not for the first time this season - his unbeaten 79 in Middlesex's two-wicket victory in Taunton may prove to be one of the defining moments of this campaign - he eased the pressure with the tempo of his batting. He survived one early edge - Eskinazi was also dropped in the morning session - but otherwise looked impressively untroubled. James Franklin, with a typically pugnacious half-century, made sure there was to be no let-up and, in the closing overs, punished a dispirited attack.

So for Middlesex, one point clear at the top of the table, the challenge goes on. And, given something most unlikely in the penultimate round of game, the title will be decided in the closing week of the season when they host Yorkshire at Lord's. It could hardly be set-up better, could it?

Nottinghamshire have less to savour. This relegation will sting for some time. There have been setbacks this season, for sure, not least the retirement of James Taylor. But for a squad blessed with this talent and these resources to have failed to win after the opening week of the season is a colossal failure to fulfil their potential.

Might a few have simply become a little comfortable? There are some on this staff who are an odd shape for professional sportsmen - sumo wrestlers aside - and their fielding on the final day let down an attack who will at full strength (and Notts expect to have Stuart Broad available a fair bit at the start of next year) prove some way above anything else in Division Two next season.

It left Mick Newell, the out-going head coach (and in-coming director of cricket) to face the media. In his gruff, northern way, it was clear that this reverse hurt him deeply.

"Relegation isn't about money," he said. "It's about shame and embarrassment. It's 10 years since I've stood here and had to explain a relegation… But that's the way it is. I guess you have to take it on the chin. It's disappointing to hand over to Peter Moores this way.

"We haven't played anywhere near well enough this season. You look at our dismissals in the second innings here and they were very slack. They weren't dismissed by fantastic deliveries. They were a bit casual. That's what cost us the game."

There won't be too many changes in personnel at the club. Greg Smith, the batsman, and Ben Kitt, a young fast bowler of some potential, have both agreed new, two-year deals and most of the senior players will be given a chance to put this right. Moores will, without doubt, be focusing on the fielding and fitness. Every team he has coached tells us that. A winter in the gym looms for a few.

To talk to some Nottinghamshire supporters over recent days, the blame for recent events lies almost entirely at the feet of Newell. And it is true there have been some unsuccessful signings: Will Gidman and Jackson Bird for a start.

Those with longer memories may recall the enormous amount of good he did. The two Championship titles; the List A trophy; the T20 knock-out stages. Sports careers, like those of politicians, almost always end in failure. But one or two of the players, all of which owe him for the opportunity he has provided them, may reflect that they have let him down in recent months.

This was also a result that said much for Middlesex's resilience. They were 39 for 4 in their first innings and 25 for 3 in their second. They were obliged to bat last on a used pitch and in the knowledge that Yorkshire were breathing down their neck. To win in such situations shows character. That last match at Lord's is already shaping up to be a classic.

George Dobell is a senior correspondent at ESPNcricinfo