SALT LAKE CITY -- Utah Governor Gary Herbert has struck a deal to craft a revised rule that effectively bans conversion therapy on LGBTQ children, FOX 13 has learned.

It follows a highly politicized and emotional fight over efforts to ban the practice in Utah, with the state's dominant religion weighing in alongside those who have been harmed by abusive practices and efforts to change their sexual orientation or gender identity.

"I have learned much through this process. The stories of youth who have endured these so-called therapies are heart rending, and I’m grateful that we have found a way forward that will ban conversion therapy forever in our state," Gov. Herbert said in a prepared statement Tuesday night. "I’m grateful to the many stakeholders who came to the table in good faith, with never-ending patience. I’m also grateful to the dedicated board members at DOPL for their work that enabled us to come together to craft this rule."

The rule is based on a bill that failed to pass the Utah State Legislature, but had support from LGBTQ rights groups, suicide prevention advocates and even The Church of Jesus Christ of Latter-day Saints. The latest version was crafted with input from all sides, as well as legislative leadership. FOX 13 is told the deal came together Tuesday night and was described by an aide to the governor as a "Thanksgiving miracle."

"What a beautiful way to start the Thanksgiving weekend. Utah will soon be the 19th state in the nation to ban conversion therapy for minors. We are profoundly grateful to the Psychologist Licensing Board and the Herbert Administration for the thoughtful and meticulous manner in which they have worked to protect LGBTQ youth. Their actions today will no doubt save lives," Troy Williams, the director of Equality Utah said in a text message to FOX 13.

The revised rule will face another round of public comment before it could become effective in mid-January.

Conversion therapy, a widely discredited practice of attempting to change someone’s sexual orientation or gender identity, has been a hotly debated topic on Utah’s Capitol Hill. LGBTQ rights and suicide prevention groups have urged a ban to help combat Utah’s high youth suicide rate.

Earlier this year, a bill was introduced in the Utah State Legislature that sought to ban the practice. However, social conservatives on Capitol Hill modified the bill to the point its own sponsor could not support it anymore. The bill's death prompted LGBTQ rights activists to protest over how it was handled, prompting a rare apology from the governor.

He then directed Utah's Department of Commerce to craft administrative rules regulating therapists to ban the practice. Thousands of pages of public comments where submitted, overwhelmingly in support of a ban on conversion therapy. Hours of public testimony also supported the ban.

But the day the public comment period ended, The Church of Jesus Christ of Latter-day Saints, a powerful influence in the legislature, raised objections to the proposed rule. It argued that the rule did not properly address parental or religious rights.

The Utah Department of Commerce did not halt the rule-making process and insisted it would go forward. Since September, the rule has been under consideration.

"We are opposed to conversion therapy and our therapists do not practice it. However, we are grateful for the clarifications the new rule provides, and we support its adoption," said Marty Stephens, director of government relations for The Church of Jesus Christ of Latter-day Saints, in a statement on Tuesday night.

This new proposal would modify that process but allow for it to go into effect ahead of the Utah State Legislature's 2020 session, where it could seen an effort to modify it to appease more conservative members. However, with a deal in place with the support of legislative leadership, any efforts to tweak it face hurdles and a certain veto by Gov. Herbert.

Rep. Craig Hall, R-West Valley City, the original sponsor of the conversion therapy ban, was ecstatic with the agreement.

"It took a little bit of a journey to find particular language that would both prohibit conversion therapy and protect legitimate interests of patients and families and therapists," he told FOX 13. "But we are thrilled to have a deal to prohibit conversion therapy in this state once and for all."

Throughout the state, political leaders and advocates weighed in on the agreement.

"Conversion therapy is immoral and dangerous, and I am glad Utah has caught up with many states to ban this barbaric practice," Salt Lake City Mayor Jackie Biskupski, who is openly lesbian, said in a statement. "Throughout this conversation the only value that should have mattered was the life and safety of our young people. Thank you to all the activists who led state officials to this conclusion."

Mayor-elect Erin Mendenhall also expressed support.

"I couldn't be happier to hear this news. Banning conversion therapy in our state is the right thing to do. I'm relieved and grateful that Governor Herbert and key stakeholders were able to work together on this rule, which will ultimately protect our children and their futures," she said.

This has been a very emotional and trying process for many and I am pleased our Executive Branch and stakeholders have found areas of agreement. Lawmakers will monitor the rule making process and its implementation to ensure the best interest of all Utahns are met. #utpol #utleg https://t.co/WVucqdSaUJ — Speaker Brad Wilson (@BradWilsonGOP) November 27, 2019

Game on! Looks like we have an agreement. Unfortunately we will go through another round of comments and a hearing. Once published on Dec 15th, we will need to get comments in again! They are still important. Hopefully this will avoid any showdowns since church is bought in. https://t.co/3pVsRpozyn — Sue Robbins (@SueRobbins31) November 27, 2019