Tom Abell and Lewis Gregory defied Essex for more than an hour and a half in deteriorating light to secure a draw in the day-night, pink-ball game at Chelmsford as Somerset closed 168 runs adrift of their target of 319.

The sixth-wicket pair came together after Somerset had lost three wickets in 11 balls to collapse to 116 for five with just 20 of their 50-over allocation used up. But they put on a masterclass of patient, defensive batting with Abell finishing on 21 from 88 balls and the limpet-like Gregory with a 90-ball 15 before the captains shook hands with one over left.

The draw enabled Essex to cut by one point the gap to third-placed Somerset, who in turn are 22 points behind leaders Surrey.

The denouement of the game was played out in front of the proverbial two men and a dog, but those present inside The Cloudfm County Ground were rewarded when a proper contest finally broke out after a three-day run-fest on a flat, batsman-friendly pitch.

Chasing at 6.4 an over, Somerset had made a promising start, rattling up 63 in 11 overs when Eddie Byrom chanced his arm to Ryan ten Doeschate and was run out by the direct hit from mid-on. Byrom’s 38, with six fours, had taken just 36 balls. Steven Davies followed to the last ball before tea when he was bowled by Harmer for 30 from 34 balls.

Somerset required 244 in a final session of a scheduled 36 overs. They came out fighting after tea, adding 21 runs in two overs, James Hildreth taking three successive fours off Neil Wagner, and George Bartlett launching Harmer for six to long-off. The stand was worth 32 in four overs when Hildreth played on to Harmer for 19 from 15 balls.

Bartlett continued the assault with a six over long-on, but next ball fell into the trap set by Neil Wagner, and top-edged to Alastair Cook who dived forward at deep fine leg.

Cook had returned to his more accustomed position in the slips in time for the next over, where he held on to an edge from Peter Trego to give Harmer his third wicket. Somerset had lost half their side and were still 203 runs from victory.

Suddenly 319 looked a distant prospect. Abell and Gregory recognised that and shut up shop accompanied by regular oohs and ahhs from the fielders in close-catching range. When the final hour was signalled at 8.18pm, Somerset were 138 for five and Westley’s off-breaks were briefly called into service.

Essex, who led by 110 runs on first innings, declared for the second time in the game on 208 for seven. Nick Browne led the way for Essex, scoring 75 from 156 balls before he was seventh out three overs before captain ten Doeschate called a halt. Browne shared a third-wicket stand of 104 in 31 overs with Ravi Bopara, who recorded his third score above fifty in four innings during which time he has scored 284 runs.

But once Bopara had departed for an 88-ball 58, Essex lost wickets at regular intervals on a flat track before they declared midway through the day, leaving Somerset a session and a half to bat.

Dom Bess ripped out the heart of the Essex batting with two wickets in four balls, and finished with three for 81 from 17 overs. Bopara, who had posted his third score over fifty in four innings with a dab to third man, was Bess’s first victim. Failing to move his feet, Bopara dollied the ball up to slip Lewis Gregory, who took the catch at the second attempt. Ten Doeschate followed, playing around one that turned and going bowled.

Browne pushed Bess to long-off for the single that took him to his second fifty of the game. It had taken 126 balls. But Bess had wicket No3 when he sent down a faster and fuller ball that Adam Wheater was too late to jam his bat down on and was also bowled.

Alastair Cook, who had to wait until five wickets down before batting after missing the whole of the third day suffering with tonsillitis, lasted just three balls before lofting Peter Trego to Jamie Overton on the fine-leg boundary.

Browne departed to a catch at long-off to an uncharacteristic slog before Harmer showed him how it was done three balls later, clearing the rope in the same corner of the sparsely-populated ground. Harmer’s big hitting carried Essex to their declaration with 30 runs from 27 balls.