A former pastor who wrote a bestselling book on traditional relationships has confirmed the end of his marriage, apologized for opposing LGBTQ rights and announced he is no longer a Christian.

Joshua Harris’ book “I Kissed Dating Goodbye,” which railed against sex before marriage and homosexuality, sold over 1 million copies and became a fixture in Christian youth groups after coming out 22 years ago.

But Harris now says the 1997 work “contributed to a culture of exclusion and bigotry,” and that he has “undergone a massive shift in regard to my faith in Jesus.”

Writing on Instagram, he added: “By all the measurements that I have for defining a Christian, I am not a Christian.”

“I have lived in repentance for the past several years — repenting of my self-righteousness, my fear-based approach to life, the teaching of my books, my views of women in the church, and my approach to parenting to name a few,” Harris wrote in the post.

“To the LGBTQ+ community, I want to say that I am sorry for the views that I taught in my books and as a pastor regarding sexuality. I regret standing against marriage equality, for not affirming you and your place in the church, and for any ways that my writing and speaking contributed to a culture of exclusion and bigotry. I hope you can forgive me,” he went on.

Harris previously confirmed his divorce in a separate post last week, announcing the end of his 21-year marriage after realizing that “significant changes have taken place in both of us”.

A group of Christians attended a pride parade to apologize for how they've treated the LGBT community

His book encouraged young people to avoid dating and remain celibate before marriage. It includes numerous sections on the dangers of lust, such as one in which Harris wrote: “Lust is a problem. And God hates it. So should you.”

The book also featured a passage in which Harris described being “checked out” by three gay men. “I’ll never forget the anger and disgust I felt at that moment,” he wrote. “It was so wrong, so filthy.”

Harris has disavowed his book on a handful of occasions in recent years, including during a 2017 TEDx Talk called “Strong Enough to be Wrong.”

He wrote a handful of other books, including “Sex is Not the Problem (Lust is)” and “Boy Meets Girl: Say Hello to Courtship.”