Labour has narrowly seen off a Brexit Party challenge to hold on to its Peterborough seat in a by-election.
Union activist Lisa Forbes retained the constituency for Labour, taking 31% of the vote and beating the Brexit Party's Mike Greene (29%) by 683 votes.
Labour leader Jeremy Corbyn called it an "incredible" win for the "politics of hope over the politics of fear".
But Nigel Farage, who founded the Brexit Party less than two months ago, called its showing "very significant".
The Conservatives came third with 21%, while the Liberal Democrats were fourth with 12%, followed by the Green Party on 3%.
- Fifteen candidates stood
- Turnout was 48.4%, down from 67.5% in the 2017 general election, when Labour beat the Tories by 607 votes
- Voters in Peterborough backed Leave by 61% to 39% in the 2016 EU referendum
- Labour leader Jeremy Corbyn, former Prime Minister Gordon Brown and Tory big guns Boris Johnson and Jeremy Hunt visited the city during the hard-fought campaign
- Theresa May, who will officially resign as Conservative leader later, did not visit the constituency
The Peterborough by-election was called after Fiona Onasanya - who won for Labour in 2017 but was convicted of lying over a speeding offence and thrown out of the party - became the first MP to be ousted under recall rules.
In her victory speech, Ms Forbes said, to cheers from her supporters, that "the politics of hope can win regardless of the odds".
"Despite the differing opinions across our city, the fact that the Brexit Party have been rejected here in Peterborough shows that the politics of division will not win," she said.
The Brexit Party had been the bookmakers' favourite to take the Cambridgeshire seat - which would have been its first at Westminster - following its success in the recent European elections.
Joining Labour's victory celebrations on a visit to the city, Mr Corbyn said: "All the experts wrote Lisa Forbes off. All the experts wrote Labour off. Write Labour off at your peril."
The Labour leader said the party had triumphed due to its anti-austerity message and its opposition to a "cliff-edge" no-deal Brexit that would threaten jobs and investment.
He challenged whoever succeeds Theresa May as Conservative leader to call an immediate general election.
Despite the Brexit Party's failure to take the seat, leader Mr Farage said he was "pretty buoyed", as it had "come from nowhere and produced a massive result".
He rejected claims that its focus on a single issue limited its appeal, telling BBC Radio 4's Today programme we have a "very strong, simple message that people believe in".
Mr Farage later handed in a letter to Downing Street calling for his party's MEPs to be included in the UK's Brexit negotiating team.
He told reporters he believed the NHS should be included in future US trade negotiations despite the political outcry when Donald Trump raised the possibility earlier this week - comments which the US president subsequently appeared to row back on.
The Brexit Party has made a huge impression - but history is written by the winners.
Had Nigel Farage's party actually won this narrowly, he would have had much more momentum to argue not just to get Brexit done by the end of October, but to have huge influence potentially over how the Conservatives choose their leader.
Had Labour lost narrowly, there would have been a big demand from the rank and file for Jeremy Corbyn to sharpen his Brexit act and to call for a referendum under all circumstances. That has not happened either.
The conclusion that the Labour leadership is drawing from this is that people actually wanted to talk about things other than Brexit.
By talking about council cuts, crime, and education, they managed not to fight on the same territory as their opponents and were able to carve out their own distinctive message, get out their core vote and sneak over the line.
Conservative leadership candidate Boris Johnson tweeted his "commiserations" to Tory candidate Paul Bristow, who, he said, "did not deserve to come third", while fellow contenders Dominic Raab, Matt Hancock and Jeremy Hunt said the result showed the threat from Labour.
Conservative Party chairman Brandon Lewis said the "clear message" from its poor performance in Peterborough as well as in recent council and European elections was the public wanted the government to deliver on the Brexit referendum result.
Polling expert Professor Sir John Curtice said the Peterborough by-election had not been as "dramatic" as the UK-wide European elections last month, in which the Brexit Party and Liberal Democrats came first and second.
But he added that the combined results had been "enough to disturb the regular rhythms of two-party politics".
Ms Forbes caused controversy during the campaign when she liked a social media post which said Theresa May had a "Zionist slave masters agenda".
Labour said she had liked a video expressing solidarity with the victims of March's terror attacks on mosques in the New Zealand city of Christchurch "without reading the accompanying text, which Facebook users know is an easy thing to do".
"She has fully accounted for this genuine mistake and apologised," a party source said.
But the Jewish Labour Movement called for Ms Forbes to have the Labour whip suspended, meaning she would have to sit in the Commons as an independent MP.
Meanwhile, Labour Against Antisemitism asked for her to be suspended from the party, calling her election a "dark day" for Labour.