Labour is braced for defeat in the Batley and Spen by-election with Sir Keir Starmer’s leadership of the party certain to come under intense scrutiny.

The party is defending a majority of more than 3,000 in the seat but the bookies have the Conservatives as odds-on favourites to follow up their victory in Hartlepool in May and heap further pressure on Sir Keir.

A result is expected early on Friday morning and one Labour source predicted a “long night” for the party, while another said the campaign had been a shambles.

Meanwhile, deputy leader Angela Rayner denied she was part of a possible bid to challenge Sir Keir if the party loses the West Yorkshire seat.

Sir Keir’s spokesman has insisted he will not resign if Labour loses but new polling this week suggested that as many as four in 10 party members would want him to quit in the wake of a loss.

The by-election was seen as a straight fight between Labour’s Kim Leadbeater and the Tories’ Ryan Stephenson, but the arrival of veteran campaigner George Galloway in the constituency provided an extra headache for Labour’s campaign managers.

Mr Galloway said he was targeting Labour voters in an explicit attempt to topple Sir Keir.

A Labour source said: “We’ve got lots of activists out but nothing’s changed.

“Galloway’s nasty campaign has hit our vote while the Tories are picking up 2019 independent votes, and places that were starting to look more positive for us seem to have swung back.

“It’s going to be a long night.”

One Labour frontbench MP predicted a 6,000 vote majority for the Tories and described the campaign as an “utter shambles” with “loads of switchers” to Boris Johnson’s party.

Ms Leadbeater said whoever won the by-election must “bring our community together”.

“There have been many highs of this election campaign but sadly there have also been some unacceptable lows,” she said.

“The acts of intimidation and violence by some who have come here with the sole aim of sowing division has been deeply upsetting to witness.”

Tory insiders sought to play down expectations as polls closed, insisting it was “too close to call”.

A Conservative source said it was “always was going to be tough – we didn’t win in 2019 and we lost by over 100,000 votes in the West Yorkshire Mayoral race”.

“On top of that, governing parties don’t normally win by-elections,” the source added – although Hartlepool showed Mr Johnson’s party was capable of making further cracks in Labour’s northern Red Wall.

In a message to voters after polls closed, Mr Stephenson said: “Whatever the result, you proved that more and more local people are ready for change.”

In a polling day video, Mr Galloway said he had a “real chance to bring about the biggest shock in British political history”.

As polls closed he added: “One thing is certain: it’s curtains for Keir.”

The Batley and Spen contest has been increasingly bitter, with clashes between Mr Galloway’s Workers Party and Labour supporters.

The most controversial arguments centre on the parties’ stance on international issues, including Kashmir and Palestine, as they battled to secure votes in the area’s various Asian communities.

Labour activists said they were pelted with eggs and kicked in the head while on the campaign trail at the weekend and West Yorkshire Police said an 18-year-old man from Batley was arrested on suspicion of assault in connection with an attack on canvassers.

Sir Keir condemned as “disgraceful” the abuse of his candidate after she was confronted by a man last week.

Ms Leadbeater is the sister of former Batley and Spen MP Jo Cox, who was murdered in the constituency in 2016.

She cast her vote early on Thursday morning in the Liversedge area of the seat, giving a thumbs-up to waiting photographers.

Ms Leadbeater has stressed she is the only one of the 16 candidates eligible to vote because she lives in the constituency.

There is a prospect of a backbench Labour revolt if the seat is lost but it is unclear if any challenger would be able to secure the support of the 40 MPs needed to trigger a leadership contest.

The Times reported an individual described as a “close ally” of Ms Rayner as saying: “There’s definitely been people sounding out the possibility — it’s clear she’d easily reach 40 nominations — and urging her to run if the worst happens in Batley.”

Ms Rayner, however, described the suggestion as “news to me”, while her spokesman said that anyone gauging support is “not doing it under instructions from Angela or with Angela’s backing” and that she is “focused entirely on her jobs”.

“She is also perfectly capable of speaking for herself and doesn’t need anyone to claim to speak for her,” the spokesman said.

The West Yorkshire constituency has voted Labour since 1997.

But a Survation poll published last week put the Tories on 47%, up 11% from the 2019 general election, while Labour was on 43%.

The Batley and Spen by-election was triggered after Tracy Brabin, who won the seat for Labour in 2019 with a 3,525 majority over the Conservatives, was elected as the mayor of West Yorkshire in May.

The full list of candidates is: Paul Bickerdike (Christian Peoples Alliance); Mike Davies (Alliance For Green Socialism); Jayda Fransen (Independent); George Galloway (Workers Party); Tom Gordon (Lib Dems); Therese Hirst (English Democrats); Howling Laud Hope (The Official Monster Raving Loony Party); Susan Laird (Heritage Party); Kim Leadbeater (Labour); Oliver Purser (Social Democratic Party); Corey Robinson (Yorkshire Party); Andrew Smith (Rejoin EU); Ryan Stephenson (Conservatives); Jack Thomson (Ukip); Jonathan Tilt (Freedom Alliance); Anne Marie Waters (The For Britain Movement)