Sir Keir Starmer has apologized to voters in Rochdale for rejecting Labour's by-election candidate, but insisted it was the “right decision”.
George Galloway secured victory in the race, finishing fourth with Labour's suspended candidate Azhar Ali.
Mr Galloway described the decision as Sir Keir's “worst nightmare”.
The Labor leader said Mr Galloway's victory was due to Labor withdrawing support for Mr Ali over widely-said anti-Semitism.
Independent candidate David Tully – a local businessman – beat the Conservatives to third place.
In his victory speech, Mr Galloway, leader of Britain's Labor Party, described Sir Keir and Prime Minister Rishi Sunak as “two cheeks of the same backside and they both got well and hit it off in Rochdale tonight”.
More about the Rochdale by-election
Mr Galloway has long campaigned for Middle East-related causes, including Palestinian rights, and said his victory was “for Gaza”.
He warned the Labor leader that his party would “pay dearly” for “enabling, encouraging and covering up disaster” in the region.
Speaking after the defeat, Sir Keir said: “I regret the withdrawal of our candidate and apologize to the voters of Rochdale.
“I made that decision. It was the right decision.”
He promised that Labor would put forward a “first class, unifying candidate” to contest the general election expected later this year.
Mr Sunak said the Rochdale contest was “one of the most divisive campaigns we've seen in recent times” but the Tories “ran a really positive campaign”.
The by-election was triggered by the death of Labor MP Sir Tony Lloyd, who held the seat with a majority of almost 10,000.
Labor had been expected to win, but their campaign was thrown into turmoil when comments by their candidate, Mr Ali, were published by the Daily Mail, widely regarded as anti-Semitic.
Mr Ali apologized for his comments but the party decided to withdraw their support and ordered its members to stop campaigning for him.
The Israel-Gaza conflict featured heavily in the by-election, with Mr Galloway telling voters in a campaign leaflet: “The people of Gaza don't have a vote in this election, you do.”
Labor is divided over how to respond to the war and last year several leading members quit their roles to vote for an immediate ceasefire.
Senior political commentator Sir John Curtis told the BBC the Rochdale decision would intensify pressure on Sir Keir to toughen Labour's stance on Israel.
However, he doubted it would have much impact on the general election results because it was “unlikely for anyone else to have the ability to exploit this issue. [the war in Gaza] in a way that Mr Galloway can uniquely do”.
Mr Tully, who polled 6,638 votes, is well known in Rochdale as he runs a garage business and is involved with the town's rugby club.
He told BBC Radio 5 Live: “I've turned the heads of people who normally don't vote because nothing really changes with mainstream politics and parties.”
Reform UK fared well in recent by-elections, coming third in both Wellingborough and Kingswood, but was beaten into sixth place by former Labor MP for Rochdale City Simon Danczuk with 1,968 votes.
The Campaign Against Antisemitism said it was “deeply concerned” by Mr Galloway's victory, saying he had a “horrendous record of inciting the Jewish community”, including calling for Bradford to be “declared a state without Israel” when he was an MP there. zone”.
If you would like to speak to a BBC journalist, please include a contact number. You can also contact us through the following ways:
If you can't read this page and see the form, you should visit the mobile version of the BBC website to submit your question or comment or email us at [email protected]. Please include your name, age and location with any submission.