Somerset's Josh Davey returned to haunt his former Middlesex teammates in a Vitality Blast thriller at Lord's to qualify for the quarter-finals.

Davey, who began his career at the home of cricket before heading to the South West, took 1-25 from four frugal overs before striking Chris Green for six as the visitors won a see-saw encounter by two wickets with two balls to spare.

The Cidermen had looked like chasing down a target of 161 with some comfort thanks to Tom Banton's 39 and 36 for skipper Tom Abell, but Jason Behrendorf's 3-30 and two wickets on debut for Max Harris made it tight before Davey's last-over heroics.

Earlier, Middlesex's tally of 160-6 owed much to Chris Green's unbeaten 44 and 41 for Luke Hollman, but it was not enough to prevent their ninth defeat of the competition.

The hosts were soon in trouble after being invited to bat, Davey getting home before skipper Steve Eskinazi was caught at cover with only seven on the board.

Max Holden too perished early, caught at deep square and John Simpson missed out skying Lewis Gregory to Will Smeed at mid-wicket.

Joe Cracknell (25) threatened briefly with two big sixes, but when he paddled Ben Green (3-38) to short fine-leg Middlesex were 55-4.

That Middlesex reached any sort of total was down to Hollman and Green. Hollman hit both Green and Peter Siddle back over their head for six before the latter extracted revenge by having the all-rounder caught in the deep.

Green was even more impressive, driving Siddle into the grandstand and plundering five fours to guide the hosts to the respectability of 160-6.

Tom Helm struck early in the chase when the dangerous Smeed miscued him into the hands of Jason Behrendorf at mid-off.

Banton struck back courtesy of a top edge over the wicketkeeper's head for six, while Rilee Roussow greeted Harris with a drive over cover for four. However, the youngster sent the man with almost 500 runs in the competition packing next ball, wicketkeeper Simpson taking a skier from a top edge.

Banton reached 39 before being castled by Thilan Walallawita's top-spinner and the hosts spied a glimmer of hope when Harris struck for a second time to remove Tom Lammonby, leaving the Cidermen 95-4.

Tom Abell swept Walallawita for six, but he perished too, losing his off-stump trying injudiciously to reverse sweep Green.

All of a sudden 42 were needed from the last four and when Jack Davies held a stunner to remove Lewis Gregory off Behrendorf the visitors were creaking.

Behrendorf removed Green to a catch in the deep only for Craig Overton to strike his first two balls from the Australian quick high into the stands.

Behrendorf's retort was to have him caught at cover to leave 10 needed from the final over, but Davey had the last word to send Somerset to the knockout stages.