After a battle over contentious anti-LGBT law HB2, North Carolina’s Governor has likely narrowly lost his re-election bid, early results show.

North Carolina has lost a string of big investment ventures over Republican Governor Pat McCrory’s decision to sign the contentious HB 2 – which voided all local ordinances protecting LGBT rights, banned transgender people from using their preferred bathroom, and permits businesses to discriminate against LGBT people on the grounds of religious belief.

The state has been plunged into crisis over the law as it shed thousands of jobs, and Democratic candidate Roy Cooper had made repealing the law a cornerstone of his campaign.

Cooper’s commitment to repealing the law had been an early hit with voters, initially taking a commanding lead over McCrory in polls.

However, the race narrowed as McCrory hit back, buoyed by heavy investment from anti-LGBT evangelical groups – who ran an ad campaign in the state depicting a little girl getting raped because of trans equality.

Despite Donald Trump comfortably winning the state in the Presidential race, the count between Cooper and McCrory went down to the wire, separated by less than 100 votes at some points in the count.

As the count concluded, Cooper appears to have pulled off a narrow victory – with 2,280,398 votes to McCrory’s 2,276,059.

The result is yet to be certified.

According to local media, the race could be upset by so-called provisional ballots expected to be counted by the time of a canvass later this month.

However, Cooper declared victory.

He said: “This has been an extremely hard fought race, but the people of North Carolina have spoken and they have chosen a change in leadership. We are confident once the results are certified we will confirm tonight’s victory.”

Cooper has vowed to repeal the law immediately when he takes office in January.

Despite sticking by the law, McCrory has lamented its impact on his social life and the election.

He lamented: “My wife, for example, she primarily stays in Charlotte. She’s been disinvited to charity events, and basically, they call her up and they say, ‘you know, you better not come. You better not come’.”

He added that friends in the business community “just this week told me they cannot support me, although you’ve been an outstanding Governor, we still cannot support you because HRC will attack us. And I’ve had at least 5 this week tell me that. At least 5. Good friends.

“Very good friends [have said] ‘Pat I love you, I love you man, we’ll be friends for life, I can’t support you’.”

Human Rights Campaign President Chad Griffin & Equality North Carolina Executive Director Chris Sgro said: “While we still await national results, Pat McCrory’s historic defeat is a beacon of hope for equality. Tonight voters said that HB2 and the politics of hate have no place in the state of North Carolina. As businesses and jobs fled the state and McCrory’s poll numbers fell, anti-equality groups rallied to his side, spending millions of dollars to bolster his faltering campaign. And we met them head on. Through our TurnOUT NC campaign, we launched the largest voter mobilisation effort in our organizational histories.

“We are confident that once the results are certified, Roy Cooper’s victory will be confirmed. By electing Roy Cooper their next governor, North Carolinians have sent a powerful message across their state and this country that the days of anti-LGBTQ politicians targeting our community for political gain are over. While McCrory may have been surprised by the overwhelming opposition in this state and across the country to his discriminatory politics, the same will not be true for lawmakers who considering doubling down on anti-LGBTQ extremism in the future. This is a wake-up call.”