Simon Harmer took nine for 95 to lead Essex to a dramatic penultimate-over victory against Middlesex and extend their lead at the top of the Specsavers County Championship to 29 points.

The South African off-spinner’s match figures of 14 for 172 was his second 14-wicket haul in successive matches, his fourth successive five-wicket return, and raised his season’s tally to 47 Championship wickets for the season to date.

When he trapped Steven Finn lbw and wheeled away in triumph, there were a maximum of eight balls remaining in the game. Harmer was given a standing ovation when he left the field after claiming his career best bowling figures.

It gave Essex their third successive Championship win. But for long periods of the final day, it looked as if Nick Compton was going to save the game for a Middlesex side who have now lost two of their last three games.

Compton batted nearly all day for 120 after six hours and 20 minutes at the crease. When he departed, the sixth of Harmer’s wickets, and Chelmsford bathed in floodlight, there were nine overs to go and Middlesex were 252 for six, chasing 296 to make Essex bat again. But four wickets went down in 27 balls as Essex recorded their second innings victory on the trot.

It had been a disappointing season for Compton, who had managed just 81 runs in four previous Championship innings this season, with a highest score of 22, after a delayed start due to injury. His 26th career first-class century encompassed 303 balls and contained 14 fours and one six.

Compton, 34 on Monday, was arguably the only batsman who came to terms with Harmer. Unlike many of the South African’s 28 victims over the last 11 days, Compton showed great respect and wariness. Apart from an early delivery he left alone as it turned in from outside off-stump, and gave him heart palpitations, he treated every ball on its merits.

However, he lost concentration when he played no shot to another from Harmer that started outside off-stump and turned, and departed lbw.

Middlesex duly folded. There were two minutes of the last hour on the clock when Steven Finn played a half-hearted shot and went lbw as Essex triumphed.