Kim Leadbeater has won the Batley and Spen by-election for Labour despite a strong challenge from the Conservatives to conclude a difficult and bitter campaign in an equally dramatic fashion.
She received 13,296 votes, a majority of 323 over Tory candidate Ryan Stephenson after a divisive contest.
George Galloway, who targeted voters in traditionally Labour areas with the aim of toppling Sir Keir Starmer, came third.
Galloway tried to attract Muslim voters by campaigning on a pro-Palestine platform.
Leadbeater paid tribute to her family and friends after winning the seat previously held by her murdered sister Jo Cox.
As she looked ahead to serving as MP for the seat Cox held until her murder in 2016, Leadbeater said she could not have survived the past five years without the support of those close to her.
“There’s way too many people to mention by name, but I do want to refer to my family and my friends, who, without them, I could not have got through the last five years, never mind the last five weeks,” Leadbeater said in her victory speech in Huddersfield.
“My amazing parents and my wonderful partner, and I want to give a special shout out to my niece and nephew who I cannot wait to hug as soon as I see them”, she added referring to the children of her late sister.
There were reports that allies of deputy Labour leader Angela Rayner were preparing the ground for a leadership challenge against Starmer if the party lost the by-election.
Starmer said: “Kim has shown inspiring resilience in the face of hatred and intimidation. She was unafraid to call it out and ran a positive campaign of hope.
“Kim embodies everything I want the Labour Party to stand for: passionate about her local community and determined to bring people together.”
After taking the seat vacated by Labour’s Tracey Brabin becoming the mayor of West Yorkshire in May, Leadbeater also thanked the police for their help during the hard fought campaign, without going into specifics.
“I want to say a huge thank you to the police who, sadly, I have needed more than ever over the last few weeks,” she said.
Leadebeater was harassed during the campaign by fundamentalist Muslims over her sexuality.
There were also leaflets distributed in the constituency by a local Imam that told people not to vote for Leadbeater as she was a lesbian.
It was alleged by some that Galloway was behind these attacks and had been telling voters about the Labour candidate’s sexuality – charges he denies.
Labour national campaign coordinator Shabana Mahmood said: “We saw a politics of fear start to take hold in that constituency and amongst those communities.
“George Galloway was allowed to go in and spread politics of fear.”