There was election night victory for the Conservatives in Calderdale as Craig Whittaker held on to his Calder Valley seat.
Mr Whittaker will represent the constituency for a third term, but with a vastly reduced majority of just 609 votes.
His win came after exit polls indicated Labour's Josh-Fenton Glynn could take the seat from the Conservatives, which has held the seat since 2010.
There was rapturous applause from Mr Whittaker's supporters as the result was revealed by returning officer Merran McRae.
Speaking on the podium, he said: "I have to thank the wonderful, wonderful people of the Calder Valley who have re-elected me for the third term in what has been the biggest roller coaster election campaign that I think I have fought in the last 25 years."
He said he felt humbled and privileged in what had been a difficult evening for the party in West Yorkshire.
Mr Whittaker added: "It's not a one-man show, it is a team effort and I have got the best team in the UK. They are fabulous. They work around the clock and this is a win for them as much as it is for me and the Conservative Party."
As in 2015, Labour's Josh Fenton-Glynn stood against Mr Whittaker in the Calder Valley, who then won the seat with a majority of 4,427.
Mr Fenton-Glynn said: "I'm feeling really proud of the campaign we have run, proud we have not hidden from any of the issues, we have talked about matters and I'm glad that voters responded.
"We've reduced Craig Whittaker's majority by 90 per cent - people want a change, people don't want the re-imagining of the welfare state this Tory Government want to bring in and it's very clear people want an MP in the Calder Valley that represents them.
"This wasn't a vote for Craig Whittaker, this was quite clearly, people not sure where to go, not happy with the status quo and I think the 90 per cent reduction in his majority shows that.
"I've got a job that I love, a wife that I love - I'm going to continue doing that and I'm going to continue being the best councillor for Calder ward I can."
He added: I've never stopped fighting for the Calder Valley - I'm a councillor here and i'm proud of where I come from. Whether that's a parliamentary fight is yet to be seen, but most importantly it's a fight for the best services."
Speaking about Labour's election night on a national scale, Mr Fenton-Glynn said: "There's no mandate for Theresa May's hard Brexit, there's no mandate for the re-founding of the welfare state in the way they want to, we'll see where we are in a couple of years."
Earlier in the night, Liberal Democrat candidate Janet Battye said the party had been squeezed by Labour and the Conservatives and said it was "disappointing" after the hard work put into the campaign.
Meanwhile, the Green Party's Kieran Turner had been said the campaign had been “really worthwhile”.
“Although it has been a weird election, with hard to predict results," he said. "The themes have been really heartwarming for us, because the themes have been very generous and unselfish."
He added that he hoped the Calder Valley would “get something better than Mr Whittaker”, adding that he did not believe he had shown respect to local people.Independent Rob Holden said he was feeling good about the campaign, but said he said he thought it a shame that the general election had been turned into a ‘presidential’ style election.
“People haven’t been voting for the local candidates, they have been voting for either Theresa May or Jeremy Corbyn,” he said.
“We’ve seen that tonight in the polls. I’ve never seen such a two-horse race in the general election in the Calder Valley for a long, long time."
UKIP's Paul Rogan was not available for comment.
The results of the Todmorden and Rastrick ward by-election were also announced. It was a Conservative hold for Rastrick as Sophie Whittaker was elected with 2,929 votes. Todmorden was held by Labour's Carol Machell with 3,648 votes.