Middlesex dethroned Yorkshire in a thrilling finish at Lord’s to win their first County Championship title since 1993.

In a race that went down to the wire, Yorkshire eventually succumbed for 178 – with Toby Roland-Jones taking 6-54 – after the two sides agreed on a target of 240 from 40 overs.

Middlesex achieved their victory with just under five overs remaining to become champions for the first time in 23 years – and end the hopes of Somerset, who would have won the title if the Lord’s clash had ended in a draw.

Resuming at 81-2 overnight, Middlesex made steady progress in the morning as Dawid Malan (116) and Nick Gubbins (93) added almost 200 for the third wicket.

The need to set up a declaration prompted a bizarre period after lunch, where Yorkshire openers Adam Lyth and Alex Lees sent down a string of slow long hops to gift the home side runs.

Stevie Eskinazi finished unbeaten on 78, with John Simpson hitting 31 from 10 balls and James Franklin (30) lobbing a return catch to Lyth to trigger the declaration at 359-6.

That left the defending champions to chase 240 from 40 overs – but they lost early wickets as Lyth (13) edged Roland-Jones to slip and Lees (20) slapped Tim Murtagh to square leg.

David Willey was promoted to three, but he could only make 11 before miscuing Murtagh to mid-on – while Gary Ballance (30) skied one into the hands of Sam Robson.

But Bresnan, whose unbeaten century in the first innings had kept his side in the title race, hammered 55 from 48 balls to lower the target to double figures.

Roland-Jones returned to trap Bresnan leg before just as the tide seemed to be turning in Yorkshire’s favour and then bowled Andrew Gale (22) to leave the visitors six down.

And as Yorkshire’s challenge wilted, Roland-Jones cleaned up the tail with a hat-trick, having Azeem Rafiq caught before bowling Andrew Hodd (17) and Ryan Sidebottom (0) to seal Middlesex’s dramatic victory.