Jane Dodds, the Lib Dem candidate, overturned a Tory majority of 8,083 to defeat incumbent Chris Davies by 1,425 votes in the Welsh constituency.
The party chose to field Mr Davies as its candidate despite him being ousted in a recall petition by 19 per cent of the electorate in the Welsh seat, after he admitted submitting false claims for expenses.
The result further weakens Mr Johnson’s grip on the Commons and could make it harder for him to pass both his Brexit plan and his domestic agenda through parliament.
It also breathes fresh hope into the prospect of other “Remain alliances”, after Plaid Cymru and the Greens threw their weight behind the Lib Dems to prevent a split in the pro-EU vote.
Speaking as she celebrated her victory in the early hours of Friday morning, Ms Dodds called on Mr Johnson to rule out a no-deal Brexit.
The Welsh Lib Dem leader said: “People are desperately crying out for a different kind of politics. There is no time for tribalism when our country is faced with a Boris Johnson government and the threat of a no-deal Brexit.
“My very first act as your MP when I arrive in Westminster will be to find Mr Boris Johnson, wherever he is hiding, and tell him loud and clear: ‘Stop playing with the future of our communities and rule out a no-deal Brexit now’.”
Labour were pushed into fourth place by the Brexit Party, winning just 1,680 votes and a 5 per cent share, down 12 per cent on what they achieved in the constituency at the 2017 general election.
A Labour spokesperson said: “We always knew this was going to be a difficult night for us, but we’re proud of our positive campaign in Brecon and Radnorshire.
“One thing is clear – voters have rejected Boris Johnson and his divisive, out-of-touch Tory government.”
Mr Davies won the seat from the Lib Dems in 2015, as the party suffered disastrous results across the country that left it with just eight MPs, down from 57.
He was ousted by his constituents earlier this year after he pleaded guilty in March to submitting two false expenses invoices for nine photographs costing £700 to decorate his new office.
Mr Davies was fined £1,500, ordered to pay £2,500 towards legal costs and told to carry out 50 hours of community service.
The loss leaves Mr Johnson with the backing of 319 MPs in Commons, including the Democratic Unionist Party, while opposition parties now have 318.
And the national significance of the result showed in the turnout. At 59.7 per cent, it may have been down from 74.6 per cent at the general election, but it was the highest for a by-election since Winchester in 1997.
Lib Dem leader Jo Swinson said: “The people of Brecon and Radnorshire have shown that the country doesn’t have to settle for Boris Johnson or Jeremy Corbyn.
“Boris Johnson’s shrinking majority makes it clear that he has no mandate to crash us out of the EU.
“As leader of the Liberal Democrats, I will do whatever it takes to stop Brexit and offer an alternative, positive vision for a richer, greener and safer future. Britain demands better than what the tired old parties can give.”
Plaid Cymru leader Adam Price hailed the “spirit of cooperation” between the pro-Remain parties as he called for a second referendum.
“But if the prime minister is intent on a general election, he should know that Plaid Cymru and the other pro-Remain parties are committed to cooperating so that we beat Brexit once and for all,” he added.
Register for free to continue reading
Registration is a free and easy way to support our truly independent journalism
By registering, you will also enjoy limited access to Premium articles, exclusive newsletters, commenting, and virtual events with our leading journalists
Already have an account? sign in
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies