Kim Leadbeater elected as MP for Batley and Spen, winning 13,296 votes, 323 more than her closest rival, Ryan Stephenson of the Conservatives
Here's how it unfolded throughout the night:
"There's lots to do...but I'm going to crack on with it" Labour's Kim Leadbeater delivers speech after being elected as MP for Batley and Spen.
The Labour Leader, Sir Keir Starmer has congratulated Kim Leadbeater on a "fantastic result" following a "positive campaign of hope, in the face of division".
Labour's Kim Leadbeater elected as MP for Batley and Spen with 13,296 votes.Ryan Stephenson (Conservatives) 12,973George Galloway (Workers Party) 8,264Tom Gordon (Liberal Democrats) 1,254Corey Robinson (Yorkshire Party) 816
It's looking very tight, with a second bundle count as we await the result.
The Yorkshire Party candidate, Corey Robinson, says it has been a “respectable" showing for his party.
The declaration is expected shortly before 5am.
The by-election turnout was low at 47.61%. There were a total of 37,786 verified ballots out of a total electorate of 79,373.
Update from the Yorkshire Party, saying they are battling with the Liberal Democrats for fourth place:
Boxes arrive at Cathedral House in Huddersfield:
Analysis from our Political Correspondent Harry Horton as voting begins:
REACTION FROM CANDIDATES
Analysis from our Political Correspondent Harry Horton as Labour is not confident of retaining their seat.
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.
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."
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)