It is ironic that the by-election result that helped Rishi Sunak avoid a 3-0 defeat should come courtesy of the Uxbridge and South Ruislip voters who elected Boris Johnson.

On paper, this was the hardest constituency to hold on to – requiring only a 7.5-point swing from the Conservatives to put it in Labour hands.

When we learned that Labour had requested a recount, the game was up. The Conservative majority was five votes short of 500 – the swing against them 6.7 points.

Labour’s critics will point out that such a swing applied nationally would see the Conservatives remaining the largest party in a hung parliament at the next general election.

Two huge Tory majorities overturned – politics latest

The simplest explanation of why Uxbridge should behave so differently to the other two by-elections is a single issue: ULEZ.

The London mayor’s decision to extend the Ultra Low Emission Zone to the entire London region has gone down badly with voters who see it as a Labour-imposed tax on those suffering most from the cost of living crisis.

More on Conservatives

The Labour candidate did his best to distance himself from Sadiq Khan’s policy, but obviously not to the satisfaction of enough of Uxbridge’s voters.

Other explanations will jockey for attention. One is that a dispute over taxation affecting different wings of the Labour Party gives hope to the Conservatives going into the next general election.

Labour’s tax and spend policies will undergo forensic examination. Another explanation is that the constituency is unusual, a rare Leave-voting London area with atypical demographic changes.

But without doubt, the outcome in Selby and Ainsty – a constituency lying close by Mr Sunak’s own seat, is deeply concerning for the Conservatives.

Previously, the largest Tory majority overturned by Labour at a by-election was 14,654 votes in the Mid-Staffordshire by-election held 33 years ago.

Labour’s winner, a youthful Keir Mather, demolished the more than 20,000 majority and replaced it with a 4,000-vote majority of his own.

This victory sends shockwaves throughout the Conservative parliamentary party and gives Labour a huge boost.

The swing to Labour in Selby is the second largest in a Conservative seat since the war – only the mammoth 29-point swing in Dudley West achieved by Blair’s New Labour in 1994 is larger.

Conservative incumbents, already pre-occupied with boundary changes affecting their constituencies, will look at their own majorities and wonder whether early retirement is a better option than waiting for the voters to ditch them – joining the 44 Tory MPs who have already declared they won’t be standing again.

Conservative MPs in seats that have stayed loyal to the party for a century – like Aylesbury, Basingstoke and Macclesfield – will fear Labour’s Selby advance. And if these incumbents are worried, what about their colleagues representing seats that fell to Labour in 1997, a defeat so devastating it took the party the next four general elections to win another overall Commons majority?

There are so many members of the Conservative parliamentary party impacted by the Selby result that it is inconceivable spinning the Uxbridge outcome will override their concerns with the party’s leadership.

The Liberal Democrats were so confident of their win in Somerton and Frome that they announced it with barely a vote counted. The swing of 29 percentage points is similar to those in other by-election seats won by the Liberal Democrats in parliament. The Conservative by-election vote share, 26%, is thirteen points lower than its previous low point seen at the 1997 general election.

This humiliation follows local elections that brought defeat for many Conservative councillors and delivered control of Somerset council to the Liberal Democrats.

Crumbs of comfort for the Conservatives are the collapse in Somerton’s turnout, suggesting supporters may have abstained, and that Lib Dem national poll ratings are currently struggling to reach double figures.

That is unlikely to settle the nerves of Conservative incumbents in the West Country – for example those in Wells and Yeovil, and further afield in Devon and Cornwall, who sense a Lib Dem revival is under way.

Generalising from by-election results is always a dangerous business. But when the outcomes disagree as much as these do, then it’s impossible to see a consensus emerging.

Both Mr Sunak and Sir Keir will try to convince their parties that the results give cause for optimism.

Significant numbers in both parties won’t believe them.

Dr Hannah Bunting is lecturer in Quantitative British Politics, University of Exeter. Professor Michael Thrasher is associate member, Nuffield College.