Republican Congressional candidate for North Carolina's 9th district Mark Harris (Sean Rayford/Getty)

A Republican who opposes the decriminalisation of homosexuality has been elected to the US House of Representatives.

Mark Harris, who has anti-gay views, won election to the Congress for North Carolina’s 9th District on Tuesday after defeating Democratic challenger Dan McCready.

He won the election with 138,338 votes (49.4 percent), claiming a narrow victory over McCready who garnered 136,478 votes (48.8 percent).

The victory for Harris comes despite an exposé in August revealing that Harris, an evangelical pro-Trump pastor, had made extreme comments about gay sex.

A recording published by Media Matters revealed that in a 2015 sermon, pastor Mark Harris lamented the “moral decay” of decriminalising homosexuality.

He claimed: “In one generation you and I have witnessed this country sliding from a nation who once shared a moral vision based on Judeo-Christian ethic to a nation floundering in moral decay… we have watched in one generation where homosexuality was once criminalized to now we see the criminalization of Christianity.”

Harris also called on women to submit to their husbands, saying: “God instructs all Christian wives to submit to their husbands. You see wives, please hear me this morning. The message is not from your husband to submit, the message is from the Lord.”

The Republican candidate also campaigned to abolish LGBT+ rights protections in North Carolina during the state’s battle over its bathroom ban, saying: “They can call it a new morality. They can call it the new normal, but God has said it’s same old sin, and I’m going to stand on the… word of the living God.”

Mark Harris has ties to anti-LGBT hate groups

Right Wing Watch reports that Mark Harris is a member of the Family Research Council’s Watchmen on the Wall network. The Family Research Council is a listed anti-LGBT hate group whose leader has been condemned for comparing gay people to Nazis.

His campaign earned support from Karen Pence, the wife of Vice President Mike Pence, who headed to North Carolina to campaign for Harris.

She said: “He’s the kind of strong, principled conservative leader who will stand with this administration to deliver results. He’s a husband, a father, a pastor, a leader. He has devoted his life to his service to others… a devoted servant of God.”

Mark Harris teamed up on the campaign trail with internet evangelical pundit Elizabeth Johnston, known as the ‘Activist Mommy,’ who has claimed LGBT groups want to “rape the minds” of children.

The Republican official will take his seat in the US House of Representatives in January.