Virginia Attorney General Ken Cuccinelli, who unsuccessfully tried to maintain a ban on oral and anal sex and believes “homosexuality is wrong”, has been defeated in the race to become state governor.

The 45-year-old Republican lost out to Democrat Terry McAuliffe in a surprisingly close victory, the votes are still being counted.

Mr Cuccinelli is a social conservative who remains opposed to LGBT equality. He also wants to make abortion and divorce more difficult.

He unsuccessfully campaigned to keep Virginia’s anti-sodomy law, which banned consenting couples, both homosexual and heterosexual, from oral and anal sex. It was struck down in March this year and last month Mr Cuccinelli was denied an appeal by the US Supreme Court.

In 2004, Mr Cuccinelli said “homosexuality is wrong.”

During his 2009 campaign for attorney general, he stated: “My view is that homosexual acts, not homosexuality, but homosexual acts are wrong. They’re intrinsically wrong. And I think in a natural law based country it’s appropriate to have policies that reflect that.”

He added: “They don’t comport with natural law. I happen to think that it represents (to put it politely; I need my thesaurus to be polite) behaviour that is not healthy to an individual and in aggregate is not healthy to society.”

Mr Cuccinelli has been a strong advocate of abstinence-only state-funded education programmes.

“The longer you delay the commencement of sexual activity, you have healthier and happier kids and more successful kids,” he said in 2007.

Meanwhile, fellow Republican Chris Christie, who fought against the arrival of equal marriage in New Jersey, has been re-elected governor of the state.