The Conservatives have lost a closely-fought Brecon and Radnorshire parliamentary by-election.
Liberal Democrat candidate Jane Dodds overturned an 8038 majority to beat Chris Davies by 1425 votes.
Mr Davies stood again after being unseated by a petition that followed his conviction for a false expenses claim.
Labour were beaten into the fourth place by The Brexit Party.
It was the first electoral test for new prime minister Boris Johnson.
Ms Dodds, who is Welsh Lib Dem leader, said: "My very first act as your new MP when I get to Westminster will be to find Mr Boris Johnson, wherever he's hiding, and tell him to stop playing with the future of our community and rule out a no deal Brexit".
Mr Davies congratulated Ms Dodds saying "I wish her well for the future" and he paid tribute to his family saying they had "a difficult time over the past few months".
It leaves the government's working majority cut to just one, including the confidence and supply partners.
The turnout was 59.7 percent, down from 74.6 percent at the general election, but it is the highest for a by-election since Winchester in 1997.
Both Plaid Cymru and the Greens did not field candidates, to try to maximise the Remain vote.
Plaid leader Adam Price said the "spirit of co-operation" between the pro-Remain parties had led to Ms Dodds's election, 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 said.
Ms Dodds, 55, lives in the neighbouring constituency of Montgomeryshire and is a child-protection social worker.
Recently elected Liberal Democrat leader Jo Swinson said: "Boris Johnson's shrinking majority makes it clear that he has no mandate to crash us out of the EU."
Labour, which at one stage feared it might lose its deposit, blamed voters switching tactically to the Liberal Democrats.
A spokesman for Welsh Labour 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 UK Tory government."
Political analyst Professor Roger Awan-Scully, from Cardiff University, said: "Labour need to look very closely at this result. Everything points to not just tactical voting for the Lib Dems but also dissatisfaction with Jeremy Corbyn and [First Minister] Mark Drakeford".