Middlesex edged out Essex in a thrilling finish at Lord’s to keep alive their hopes of reaching the Royal London One-Day Cup quarter-finals.

The visitors seemed set to seal their own place in the last eight as they chased a modest target of 220 – but a late collapse ensured Middlesex clinched victory by just four runs.

It means Essex must win their final group match against Gloucestershire to be certain of qualifying for the knockout stages, while Middlesex can also go through if they beat Surrey on Tuesday.

Put in to bat, Middlesex were never really able to force the pace against the accuracy of the spinners, particularly the impressive Dan Lawrence who returned figures of 3-35.

Paul Stirling (17) edged Graham Napier behind, but the home side looked reasonably solid at 87-1 – until they lost Sam Robson (41), Nick Gubbins (21) and George Bailey (4) to Lawrence in quick succession.

James Franklin (55) and John Simpson (33) dug their side out of trouble with a fifth-wicket partnership of 62, but progress was slow and Essex continued to tighten their grip.

Franklin struck three fours in an over from Matt Quinn to bring up his half-century, but he and Ryan Higgins (18) fell to successive deliveries from Napier (3-50) as Middlesex clambered to 219-8.

Browne got the Essex reply off to a brisk start with a string of boundaries, putting on 57 for the first wicket with Tom Westley (18) before the latter hooked Roland-Jones (4-40) to deep square-leg.

Franklin had Jesse Ryder (16) caught at mid-off and also bowled Browne – who had survived a couple of close calls, including a cut shot that crept through the hands of Gubbins at gully – to make 79 from 94 balls.

Essex still looked clear favourites at 141-3 – but the gap narrowed as Roland-Jones picked up the key wickets of Ravi Bopara (34) and Ryan ten Doeschate (19).

Ashar Zaidi, whose late fireworks had clinched an Essex win at Lord’s in the T20 Blast three days earlier, seemed set for a repeat performance but, when Franklin (3-25) trapped him leg before in the final over, the visitors could only finish on 215-9.