Essex 542 for 3 dec (Browne 221, Cook 193, Chopra 100*) beat Middlesex 246 (Stirling 77, Eskinazi 66, Malan 60, Harmer 5-77) and 262 ( Compton 120, Stirling 55, Harmer 9-95) by an innings and 34 runs

Chelmsford is the birthplace of the artist Grayson Perry and was also the town where the 16th century magician, John Dee, was educated. It is therefore well-used to astonishing transformations. However, whether credulous or sceptical, residents will have seen little to compare with the latter stages of this match, when Simon Harmer engraved his name in folk memory of Essex cricket-lovers on one the greatest day's sport seen on this ground.

In November 2015 Harmer was playing for South Africa in a Test match at Nagpur. Since then he has seen his stock fall in his home country and in the winter he committed himself to a career as a county cricketer with Essex.

Last week he took 14 wickets against Warwickshire and on this wonderful last day against the champions he collected a career-best 9 for 95 finishing the match with figures of 14-172. By doing so he sent a thousand or so hardy souls at the County Ground into floodlit ecstasy, for they had seen their side complete their third victory in succession and this with a maximum of eight balls remaining in the game.

When they descend from their rare euphoria, Essex supporters may realise that their team is now 29 points clear at the top of the Division One table. What they will also understand is that they have witnessed a victory the unlikelihood of which made it all the more worthy of celebration.

With six overs left to be bowled Essex still needed four wickets and doubts began to creep in among spectators, even if the hesitancy of the later Middlesex batsmen encouraged hope among Ryan ten Doeschate's players. That belief was fuelled by the fact that the pink Duke's ball was retaining its bounce more than the red variety, a fact which the 6ft 2ins Harmer had been able to exploit throughout the match. And the problems of the Middlesex batsmen were increased by Harmer's ability to use the footholes left by Mohammed Amir and Paul Walter. For all that time was running out, one never felt that Dawid Malan's batsmen were comfortable. Certainly they never looked like clearing the 296-run deficit established by Essex's dynamic batting on the third day of this game.

In the 108th over of the innings Ryan Higgins played inside what looked like an arm ball and was caught at slip by Alastair Cook, for whom this match was the pleasantest of temporary farewells before the Test series. Three balls later Ollie Rayner collected a pair when he was leg before on the front foot. Harmer had now taken all eight wickets to fall in the innings but his chances of taking all ten disappeared three overs later when Dan Lawrence trapped Toby Roland-Jones lbw for a single although there was a case the ball pitched outside leg. Nobody minded, least of all Harmer who brushed away Lawrence apologies in the joy of shared achievement. Three balls of Harmer's subsequent over passed and it seemed clear that Lawrence or possibly Amir would be bowling the last over of the game.

That over was never delivered. Perhaps scared of commitment, Steven Finn plunged forward but played no shot to Harmer's third last ball of the game. An appeal followed that could be heard in either of the Baddows. There was a raised finger from David Millns. Harmer began the first Essex bowler since Mark Ilott in 1995 to take nine wickets in an innings and ten Doeschate's men are hot favourites for the title now. This will be Harmer's match but so was last week's.

"It's not going to get too much better than this," said Harmer. "You just need to ride the wave - they don't come around that often. We will enjoy tonight and have a few beers. It's an incredible win for the club. It puts us in phenomenal position going into the last six games of the season. We've done a lot of hard work, a lot of hard graft and been on top of our game. We've come out on top in the last 10 minutes of the day today. These are the moments you play cricket for. It makes all the hard graft worth it."

And yet it takes two teams to make a contest as noble as this one and in the joy of Harmer's achievement, even the Essex supporters spared applause for Nick Compton, whose innings of 120 looked likely to frustrate Essex. And the Middlesex opener's tale shares a very rough parallel with that of Harmer.

Just over a year ago Compton's name was blazoned in headlines. He was an England batsman. Yet within a few weeks some who had advocated his selection were vehement that he should never have been picked in the first place. No one, of course, has mentioned his name in connection with the England side for next week's Test at Lord's. Yet as we watched Compton make his century and bat in vain to save the game it was plain that he still retains the skill to play this game at a high level and the temperament to defy opponents in full cry.

Harmer v Compton. Given a couple of different turns on the wheels of fortune and circumstance, it was a battle which might have been seen in next week's Test match. And on the evidence of this quite wonderful last day at Chelmsford it would not have disgraced the stage at St John's Wood.

Compton arrived at New Writtle Street having scored 81 championship runs in four innings; injury and indifferent form have kept him out of the Middlesex team. Those factors by themselves were enough to make his effort at Chelmsford admirable. Yet the virtues of his batting were magnified by the intensity of the contest and the fact that his principal adversary, Harmer, is in the form of his life.

So much was proved in the first half hour of play when Harmer dismissed Nick Gubbins, Stevie Eskinazi and Dawid Malan in five overs from the River End, reducing Middlesex to 51 for 3 and encouraging the hopes of home supporters that they were about to see ten Doeschate's team achieve a facile innings victory and their fifth Division One triumph of the season.

Yet this early clatter was misleading; instead of offering a strong clue to the narrative of the day, it merely set up the terrific duel of Thursday's cricket: Both our principals had considerable help, of course. The main assistance to Harmer probably came from Dan Lawrence, whose high action gave his off-spinners every chance to bounce uncomfortably.

Compton was assisted deep into the heart of the day and beyond by Paul Stirling, who batted with commendable coolness and against his attacking instincts to make 55 in 202 minutes. While Compton and Stirling were adding 153 in 55 overs the five points for a draw were plainly secure. Then, five minutes before tea, Stirling, who had been dropped three times, was safely caught by Ravi Bopara at backward short leg. John Simpson resisted for 50 minutes but was beaten by Harmer's turn and taken by Cook. Then Compton having faced 303 balls, 59 more than in his entire season before this innings, was leg before playing no shot to Harmer. The door was open and the Essex cricketers plunged through it. "Harmer's a proper bowler," said Essex's eminence grise Keith Fletcher, who faced a few and has seen countless more. No one anywhere in Essex doubts that judgement this glorious June evening.

Paul Edwards is a freelance cricket writer. He has written for the Times, ESPNcricinfo, Wisden, Southport Visiter and other publications