Republican lawmaker Nathan Ivie says it took him more than 20 years to come to terms with his identity.

But Wednesday morning, the 40-year-old Utah County commissioner sat in front of his computer and publicly shared the secret that has caused him pain and confusion since he was 9 years old: He is gay.

In a video posted to Facebook that has since been viewed more than 11,000 times, Ivie embraces his sexual orientation and recounts the difficult experience of growing up feeling at odds “spiritually and biologically.” Ivie is a member of the Church of Jesus Christ of Latter Day Saints, but he declined to comment on his faith. The Utah-based faith strictly opposes gay marriage and still considers same-sex relationships to be a serious transgression.

Many residents of Utah County, which is south of Salt Lake City and includes the church-owned Brigham Young University, are members of the church.

The confusion Ivie felt led to his attempted suicide at age 22, then attempts to “cure himself” of gay feelings, he said. The first-term commissioner said his announcement was inspired in part by his work with families who have lost LGBTQ children to suicide.

“That really makes you re-evaluate your life, and what you’re doing as a leader to prevent that kind of stuff,” Ivie said.

Interacting with gay couples through his passion for the outdoors and photography helped Ivie accept himself, he said. He recently had the opportunity to photograph a same-sex couple for their wedding.

“The love they shared and the way they looked at each other was the same as any other couple,” he said. “It helped me realize, ‘Maybe I’m not broken.’”

Ivie choked up reflecting on the support he has received from family and friends since coming out, which he said has only strengthened his relationships.

“It’s been liberating, just a huge burden off of my shoulders,” he said.

Jackie Biskupski, the first openly gay mayor of Salt Lake City, joined a chorus of local politicians who applauded Ivie’s decision to come out: “All the best to you, I love how a simple act of love among strangers helped you find your truth and that you are being embraced by family and friends,” she wrote to Ivie on Twitter.

Fellow Utah County Commissioner Tanner Ainge also tweeted his support.

“My instinct is just to embrace @IvieNathan. Today I stand with him as a friend, valued colleague, and fellow Republican. His story will provide strength and hope to those feeling the lonely despair that almost took his life and has taken too many in our community #HeartOfUtah,” Ainge tweeted.

Though Ivie and his wife of 13 years have decided to separate, they will co-parent their two young children. They recently spent Mother’s Day together, and he still refers to her as his best friend.

Ivie said he hopes the announcement encourages other young people struggling with their identities to accept themselves.

“It’s OK to be different, it’s OK to live authentically,” he said. “You can be gay and a Republican ... you need to trust that people will love you for who you really are.”

FOLLOW NBC OUT ON TWITTER, FACEBOOK & INSTAGRAM