ARTICLE AD BOX
By Sir John Curtice
Professor of Politics at Strathclyde University
It was a night of contrasting results.
The Conservatives unexpectedly held on to seemingly vulnerable Uxbridge, but lost supposedly safe Selby to Labour.
Meanwhile, in Somerton and Frome, the Liberal Democrats pulled off a spectacular victory.
As a result all three main parties had a prize they could celebrate.
Labour needed just a 7.5% swing from the Conservatives to capture Boris Johnson's former Uxbridge seat. That was well below the 15% swing to the party in the latest national polls.
It was also less than the average swing of 11% Labour had previously secured in by-elections in three safe seats that have taken place since the demise of former PM Liz Truss.
Yet the party fell a little short of what was needed.
Nevertheless, at the same time Labour captured Selby and Ainsty on a 23.7% swing, the second biggest ever swing from Conservative to Labour in a post-war parliamentary election.
Indeed, Labour have not previously secured a by-election win in a seat that was previously so safe for the Conservatives. The last time Labour secured swings of over 20% was in the 1992-7 parliament, which, of course, concluded with the Conservatives being ejected from office.
Meanwhile, in Somerton and Frome the Liberal Democrats secured as much as a 29% swing from the Conservatives.
That was slightly less than the swing the Liberal Democrats enjoyed in their previous by-election victories in North Shropshire and in Tiverton and Honiton - yet it still represented the fifth biggest swing from Conservative to Liberal Democrat in any post-war by-election.
The Liberal Democrats have been making the spectacular seem routine.
But what broader lessons, if any, can be discerned from such a contrasting set of results?
Both the Conservatives and Labour agree that a local issue - London mayor Sadiq Khan's proposed extension of London's low emission zone to the capital's outer boroughs - played an important role in helping shore up the Conservative vote.
Indeed, the newly elected Conservative MP himself suggested the issue was crucial - and did not give Rishi Sunak and his government any credit for his success.
Together with the heavy scale of the party's losses in Somerton (a fall of nearly 30%) and in Selby (a drop of 26 points), it would seem unwise for Tory MPs to draw any conclusion other than that their party is still in deep electoral trouble.
Meanwhile, as in previous by-elections over the last couple of years, voters registered their dissatisfaction with the Conservatives by switching to whichever opposition party appeared best able to defeat the local Conservative candidate.
In Uxbridge and in Selby, the already low Liberal Democrat vote was badly squeezed, while in Somerton, Labour were pushed into fifth place. In a general election such a pattern of tactical voting could seriously accentuate the scale of Conservative losses.
Yet at the same time, Labour's failure to take Uxbridge will raise questions about the effectiveness of Sir Keir Starmer's electoral strategy. Characterised as it is by few promises and a focus on the centre ground, his critics may well argue that Labour's appeal proved too brittle when confronted by a difficult local issue.
Of course, Sir Keir himself may well feel the outcome illustrates the risk of promoting radical policy options.
The Liberal Democrat leader, Sr Ed Davey, will be delighted with his party's fourth by-election gain in this parliament - the party has not taken so many Tory scalps since the 1992-7 parliament (again a bad omen for the Conservatives). But whereas Labour is riding high in the national polls, the Liberal Democrats have still made little advance nationally.
The Liberal Democrat leader still has to find a way of turning his by-elections successes into a springboard for a wider revival for his party.
But it is Rishi Sunak who has the biggest headache. The coalition of Leave supporters that delivered Boris Johnson his majority in 1997 has collapsed - nearly half are no longer supporting the party, while Brexit itself has lost its allure for some voters.
The Tory leader needs to find a new tune for his party. But with living standards falling, the economy faltering, and public services struggling, enticing voters back into the Tory fold still looks far from easy.
John Curtice is Professor of Politics, University of Strathclyde, and Senior Research Fellow, National Centre for Social Research and The UK in a Changing Europe.