The Liberal Democrats have won the Brecon and Radnorshire by-election, leaving new PM Boris Johnson with a Commons working majority of just one.
Jane Dodds overturned an 8,038 majority to beat incumbent Conservative Chris Davies by 1,425 votes.
Mr Davies stood again after being unseated by a petition following his conviction for a false expenses claim.
It was the first electoral test for Mr Johnson just eight days after becoming prime minister.
It is the quickest by-election defeat for any new prime minister since World War Two.
Now, with the thinnest possible working majority, he will have to rely heavily on the support of his own MPs and his confidence-and-supply partners the DUP to get any legislation passed in key votes.
It was also a bad night for Labour, whose vote share dropped by 12.4% as it was beaten into fourth place by the Brexit Party.
The result means the Lib Dems now have 13 MPs.
Ms Dodds, who is the Welsh Liberal Democrat 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.”