Labour “is coming home” after the party narrowly held on to Batley and Spen in a sometimes brutal byelection, Keir Starmer has said, arguing that voters were starting to see through the government’s “politics of misinformation”.

“It is a start. Labour is back. Labour is coming home,” the party leader told cheering activists in the West Yorkshire constituency, standing next to Kim Leadbeater, who won the seat over the Conservatives by just 323 votes.

Leadbeater, the sister of Jo Cox, who represented the seat from 2015 until her murder by a far-right extremist in 2016, took 13,296 votes, against 12,973 for the Tory candidate, Ryan Stephenson

George Galloway, who stood under the banner of his Workers Party of Britain with the explicit aim of splitting the Labour vote and destabilising Starmer’s leadership, came third with 8,264 votes.

Speaking to activists and the media in the constituency, Starmer condemned the abuse Leadbeater had faced during the campaign, saying others had “poisoned it with hatred, division, disinformation, lies, harassment, threats and intimidation”.

While much of his message was aimed at Galloway, Starmer condemned the Conservatives for believing “they could sit back, say nothing about harassment, and walk in. And they were wrong about that.”

Speaking to Sky News, Starmer sought to more explicitly link a “victory of hope over division and decency over hatred” to the government, saying a number of Tory voters had switched to Labour.

Asked if the result was affected by the resignation of Matt Hancock for breaching Covid rules during an affair with an aide, Starmer said: “I think people are getting fed up with the politics of misinformation, half-truths, untruths and division.”

The result, which Labour had feared would not go its way, was declared at about 5.25am on Friday after two “bundle checks” – not a full recount, but where the piles of votes are flicked through for irregularities. The result eases the pressure on Starmer, after a humiliating defeat in Hartlepool in May.