Labour has held on to the marginal seat of Peterborough, overturning predictions that the contest could deliver a first byelection victory for Nigel Farage’s Brexit party.

The victorious Labour candidate, Lisa Forbes, told her supporters after the count early on Friday: “Tonight’s result is significant because it shows that the politics of division will never win.”

Forbes won 10,484 votes, beating the Brexit party’s Mike Greene, who took 9,801 votes, a margin of 683. The Conservatives were beaten into third place with 7,243 votes. Turnout was 48%.

Farage left the count through a backdoor minutes before the result was announced.

After the result, Jeremy Corbyn said the Tories had been pushed to the margins because of the government cuts and its disastrous handling of Brexit.

“This result shows that in spite of the divisions and deadlock over Brexit, when it comes to a vote on the issues that directly affect people’s lives, Labour’s case for real change has strong support across the country. I look forward to welcoming Lisa to parliament next week,” he said.

Greene said the Brexit party had made a significant breakthrough, despite not winning. “We have shaken up British politics with none of the data that is necessary to win a parliamentary election,” he said. “We’ve had two parties ruling for decades, that’s not happening any more.”

Facebook Twitter Pinterest Brexit party candidate Mike Greene gives a thumbs down as Lisa Forbes gives her winner’s speech. Photograph: Joe Giddens/PA

Speaking on Friday morning, Farage insisted his party had done well. “Whichever way you cut it, we’ve come from nowhere, produced a massive result,” he told BBC Radio 4’s Today programme. “We haven’t quite got over the line but we’re pretty buoyed by this.”

He added: “Here’s the important thing – eight weeks ago today the Brexit party launched. And I think what you’ve seen from this result last night is that British politics has fundamentally changed. It’s no longer just two parties contesting.”

Farage said the relatively high Conservative vote was the key factor: “There are now seats like this, over the country, where voters are going to start to realise that if you vote Conservative you’re going to finish up with a Corbyn government. Once that gets through we’ll begin to see tactical voting.”

Labour’s shadow transport secretary, Andy McDonald, told BBC1’s Breakfast that the party had “won against the odds, and I’m absolutely delighted”.

Facebook Twitter Pinterest Mike Greene and Nigel Farage have a drink at The Bull public house in Newborough before votes were counted. Photograph: Joe Giddens/PA

He said: “It’s a very good night for Labour. And there’s really no other way to try to spin this. We were supposed to lose – we won.”

Stewart Jackson, the former Conservative MP for Peterborough, said the Tories suffered because of the failings of the parliamentary party. “There has been no leader and Brexit policy has been a shambles. Once we deliver Brexit, and get a new leader in place, I think this seat will be back in contention,” he said.

The Liberal Democrats came fourth in the byelection with 4,159 with the Greens fifth with 1,035 votes.

Brexit party insiders said Labour’s reliance upon a mainly Pakistani vote in inner-city wards had been the difference between the parties.

Labour dismissed the theory a “racist trope”.

Facebook Twitter Pinterest Independent candidate Bobby Elmo Smith watches the byelection count. Photograph: Darren Staples/Getty Images

The result is a setback for Farage’s fledgling party, which argues for a no-deal departure from Europe and made a strong showing in last month’s European elections, securing the largest share of the vote and winning 29 seats. This was the first Westminster constituency it has contested since it was founded four months ago.

Although an opposition party is expected to win byelections, Labour was seeking victory in a seat where 60% of people voted to leave the EU.

Labour activists acknowledged they also had to combat anger over the party’s selection of Fiona Onasanya as its last candidate. She was forced to stand down following a recall petition after lying to police about a speeding ticket.

The victory will help Corbyn in his fight with critics within the party who have tried to persuade the Labour leader to change course over Brexit. Shadow cabinet members such as Emily Thornberry have urged him to strongly campaign for a second referendum.

Other senior figures, such as the party chair Ian Lavery, have argued that Labour will be decimated in parts of northern England and Wales if it attempts to run another referendum.