Image copyright PA Media Image caption The victory for Jane Dodds means the Lib Dems now have 13 MPs

Liberal Democrat leader Jo Swinson said the Brecon and Radnorshire by-election was a "great victory" for her party.

In truth, the Lib Dems were the favourites to win this seat, despite having to overturn a majority of eight thousand.

They have a history of support in the area and were well-organised on the ground.

So what does the result tell us about the party's prospects for a general election?

Brecon and Radnorshire was the first major test for the so-called "Remain Alliance" and the lack of competition from the Green Party and Plaid Cymru helped the Lib Dems to get over the line.

The success provides a blueprint for pro-EU parties in future elections. The question now is the extent to which the Lib Dems are prepared to return the favour.

They would likely stand aside in Brighton Pavilion, home to Green MP Caroline Lucas and Dwyfor Meirionnydd, home to Plaid's Liz Savile Roberts. But will the pact be more widespread than that?

Any such arrangement is unlikely to spread to Scotland, where the SNP - another ardently pro-Remain party - is the dominant force.

'Grown-up conversation'

A cross-party initiative called "Unite to Remain", led by the former Conservative turned Independent MP, Heidi Allen, is currently analysing between 150 and 180 seats in England and Wales to see which party has the best chance of returning an MP.

Ms Allen says it has to be a "grown-up conversation" that ensures "every party has something to gain".

By contrast, the pro-Leave vote in Brecon was split. Had the Brexit party stood aside, the Conservatives could have retained the seat.

There's also some frustration in Downing Street that the local Tory party reselected a candidate who was convicted of making a false expenses claim.

Nevertheless, there are some positive signs for the Conservatives.

Polls suggest that Boris Johnson is bringing Brexit Party voters back to the Tories and there was evidence of this in Brecon and Radnorshire.

The Conservatives' vote share fell by 10 per cent compared to 25 per cent in the last by-election under Theresa May, in Peterborough.

Many commentators had expected the Brexit Party to gain more than 3,331 votes, but it's clear that Nigel Farage's party is still an electoral force.

The by-election serves as a reminder to the new prime minister that until Brexit is delivered, many Leave voters are reluctant to give the Conservatives the benefit of the doubt.

Knife-edge votes

A general election before Britain leaves the EU would be risky, to say the least.

You could say there's been a "Boris Bounce", but the new prime minister requires a "Johnson Jump" to be confident of winning a majority.

It's not hard to see why Boris Johnson could be tempted to call an election, given the numbers in Parliament.

The government now faces the prospect of more knife-edge votes over Brexit in the autumn, with a working majority of just one.

In reality, it will take more than one Conservative MP to rebel to cause Mr Johnson's first Commons defeat.

This is because the government's numbers don't include Charlie Elphicke, a Conservative who's had the whip removed while he fights sexual assault allegations, and a handful of opposition MPs who tend to vote with the government on Brexit.

But there's a sizeable group of Tory MPs - some of them recent Cabinet ministers - who could prove to be a thorn in the prime minister's side.

Boris Johnson could face a confidence vote in the first week of September, and he'll need all the votes he can get.