Labour has fought off a strong challenge from Nigel Farage's new Brexit Party to win the Peterborough by-election.
Unite activist Lisa Forbes was elected with a majority of 683 over the BrexitParty in a closely-fought contest.
The result will come as a disappointment to Mr Farage, who had been hoping his party would secure its first MP less than six months after it formed.
It will, however, be a relief for Jeremy Corbyn after Labour's dismal showingin the European elections amid criticism that it had failed to take a clear lineon Brexit.
The Conservative candidate Paul Bristow was third.
Click below to watch a full report from ITV News Anglia's Matthew Hudson.
In her victory address, Ms Forbes hailed the result and the defeat of theBrexit Party.
"Despite the differing opinions across our city, the fact that the BrexitParty have been rejected here in Peterborough shows that the politics ofdivision will not win," she said.
Ms Forbes called her victory "significant", because "it has shown that thepolitics of hope can win regardless of the odds".
Watch the declaration of the Peterborough by-election result
"The people of Peterborough have placed their trust in me and I will not let you down.
The defeated Brexit Party candidate Mike Greene said they could not matchLabour's organisation on the ground.
"Two parties have been ruling this country for decades. That is not happening anymore. We were ahead of the Tories, only 683 votes behind Labour.
"They have decades of data. We had nothing just four weeks ago. We did not have the vote numbers they had. We didn't have the voting history they have.
"We will be back. Let's see what does happen in the next general election."
Labour's vote share fell by more than 17 percentage points from the 2017general election while that of the Conservatives was down by more than 25percentage points.
The Brexit Party captured a 29% share of the vote, while Labour had 31%.
The turnout in the by-election was 48.4% which is higher than normal for a by-election.
The last parliamentary by-election in Newport West had a turnout of 37.1% and the one before that in Lewisham East had 33.3%.
At the 2017 General Election in Peterborough the turnout was 67.5%.
Full Peterborough by-election result
Lisa Forbes (Lab) 10,484 (30.9%)
Mike Greene (Brexit) 9,801 (28.9%)
Paul Bristow (Con) 7,243 (21.4%)
Beki Sellick (LD) 4,159 (12.3%)
Joseph Wells (Green) 1,035 (3.1%)
John Whitby (UKIP) 400 (1.2%)
Tom Rogers (CPA) 162 (0.5%)
Stephen Goldspink (Eng Dem) 153 (0.5%)
Patrick O'Flynn (Soc Dem) 135 (0.4%)
Howling 'Laud' Hope (Loony) 112 (0.3%)
Andrew Moore (ND) 101 (0.3%)
Dick Rodgers (CG) 60 (0.2%)
Peter Ward (Renew) 45 (0.1%)
Pierre Kirk (UKEUP) 25 (0.1%)
Bobby Smith (ND) 5 (0.01%)
For many years the Peterborough constituency has been a marginal seat that switched between the Conservatives and Labour from election to election.
The by-election was called after voters in Peterborough became in the first in Britain to effectively sack their sitting MP.
Fiona Onasanya was jailed in January after being convicted of perverting the course of justice. She had lied to police over a speeding offence.
A recall petition was signed by nearly 20,000 voters in Peterborough which removed Ms Onasanya from office.
Fiona Onasayna won the Peterborough seat for Labour in the 2017 General Election beating the incumbent Conservative MP Stewart Jackson by just 607 votes.