LONDON — Britain’s opposition Labour Party on Friday scored an unexpected if narrow victory in a battle for an open Parliament seat that was widely seen as a critical test for the party’s leader, Keir Starmer, who has been under pressure for failing to revive the party’s fortunes.
Many had expected that the Conservatives would take the seat, which Labour has held since 1997. And the victory will be a big relief for Mr. Starmer, who faced criticism in May when his party lost a by-election in Hartlepool, another former stronghold in the north of England.
That result added weight to the idea that support for Labour had collapsed in the “red wall,” former industrial areas of England in which Prime Minister Boris Johnson’s Conservatives have been making big inroads.
Results announced early Friday gave the Labour candidate, Kim Leadbeater, a win of just 323 votes over her Conservative Party rival, Ryan Stephenson, after an acrimonious contest in Batley and Spen, one of Labour’s traditional heartland seats in northern England.
Voting in the by-election took place on Thursday after a campaign marred by claims of intimidation, including one episode in which Ms. Leadbeater was heckled aggressively, and another after which the police arrested a man on suspicion of assault in connection with an attack on Labour supporters.
Ms. Leadbeater acknowledged that it had been “a grueling few weeks” but added, “I am absolutely delighted that the people of Batley and Spen have rejected division and they voted for hope.”
Labour fought hard to retain Batley and Spen, which was represented in Parliament by Ms. Leadbeater’s sister, Jo Cox, until she was murdered by a far-right activist in 2016.
Ms. Leadbeater’s narrow path to victory was a complicated one. She was competing not only against the Conservative candidate, Mr. Stephenson, but also against George Galloway, a former lawmaker and veteran left-wing campaigner who sought to divert support from Labour.
Although Labour held off the challenge from Mr. Galloway, its share of the vote in Batley and Spen was lower than in the 2019 general election.
Since the Brexit referendum in 2016, Mr. Johnson’s Conservative Party has succeeded in winning over many of Labour’s core voters in working-class communities in the north and middle of England.
Before the result in Batley and Spen, there had been media speculation that Mr. Starmer would be vulnerable to a leadership challenge if Ms. Leadbeater lost, as many were expecting.
Most analysts believed that Mr. Starmer would have been safe regardless of the result, because there is no credible alternative waiting in the wings. But the victory — narrow as it was — will be especially welcome news for the party leaders, because the contest could have been avoided.
The by-election was triggered in May when the area’s former Labour lawmaker, Tracy Brabin, was elected to another job as West Yorkshire mayor, requiring her to step down from Parliament. Mr. Starmer was accused of mismanaging the situation and putting the seat at risk by allowing her to run for the mayoral position.
Since he took the job of leader last year, Mr. Starmer, a former top prosecutor, has tried to unite the party after it was defeated in 2019 parliamentary elections under the stewardship of Jeremy Corbyn, its left-wing then-leader.
Mr. Starmer’s critics have accused him of a lack of charisma and of failing to set out a convincing alternative policy agenda to that of the Conservatives.
His defenders have appealed for patience and have contended that the pandemic has made it hard for the opposition to impress voters whose attention is focused on government efforts to bring Covid-19 restrictions to an end.
In his election literature, Mr. Galloway had called on voters to abandon Labour to increase pressure on Mr. Starmer and force him out of his job.
When the count was completed early Friday, Ms. Leadbeater won 13,296 votes, Mr. Stephenson was in second place with 12,973 and Mr. Galloway third with 8,264.
Labour “won this election against the odds,” Mr. Starmer said. “And we did so by showing that when we are true to our values — decency, honesty, committed to improving lives — then Labour can win.”