SALT LAKE CITY (AP) — The Mormon church joined lawmakers, the governor and advocates to back a deal Thursday that would legalize medical marijuana in conservative Utah after months of fierce debate.

The compromise comes as people prepare to vote in November on an insurgent medical marijuana ballot initiative that held its ground despite opposition from The Church of Jesus Christ of Latter-day Saints.

Gov. Gary Herbert said he'll call lawmakers into a special session after the midterm election to pass the compromise into law regardless of how the initiative fares. If it passes, it will be revised under the terms of the deal. It if fails, the Legislature would consider a law under the new framework.

The agreement in such a conservative state underscores the nation's changing attitude toward marijuana. Medical use now is legal in more than 30 states and also is on the November ballot in Missouri. So-called recreational marijuana goes before voters in Michigan and North Dakota. If passed, it will be a first for a Midwestern state.

The Utah-based faith had opposed the ballot proposal over fears it could lead to more broad use, but ranking global leader Jack Gerard said they're "thrilled" to be a part of the effort to "alleviate human pain and suffering."

7 PHOTOS Legal marijuana sales, dispensaries around the US, recreational and medical See Gallery Legal marijuana sales, dispensaries around the US, recreational and medical NEW YORK, NY - JANUARY 07: A man leaves Columbia Care, the first medical marijuana dispensary in New York City on January 7, 2016 in New York City. The law allowing medical marijuana was signed by Governor Andrew Cuomo in 2014; the law stipulates that the legal marijuana may not be ingested by smoking it. (Photo by Andrew Burton/Getty Images) Corey Young, a founder of courier service CannaRabbit LLC, picks up a delivery of marijuana from a dispensary as part of a wholesale transfer in Denver, Colorado, U.S., on Friday, March 27, 2015. CannaRabbit and peers are rushing in as regional truckers and nationwide haulers United Parcel Service Inc. and FedEx Corp. steer clear of transporting marijuana on concerns over the lack of nationwide clearance of a practice that is still illegal in most states. Photographer: Matthew Staver/Bloomberg via Getty Images WASHINGTON, DC - MARCH 8: Takoma Wellness Center is a family run medical marijuana dispensary in Washington, DC. Employee, David Malpica, sets up the dispensary room before business hours on Sunday, March 8, 2015. (Sarah L. Voisin/The Washington Post via Getty Images) Marijuana sits on a counter after being delivered to a dispensary by the courier service CannaRabbit LLC in Louisville, Colorado, U.S., on Friday, March 27, 2015. CannaRabbit and peers are rushing in as regional truckers and nationwide haulers United Parcel Service Inc. and FedEx Corp. steer clear of transporting marijuana on concerns over the lack of nationwide clearance of a practice that is still illegal in most states. Photographer: Matthew Staver/Bloomberg via Getty Images LOS ANGELES, CA JULY 05, 2014 --- Shoppers lined up at one of many pot vendors stall at cannabis farmers market organized by California Heritage Market at West Coast Collective, a marijuana dispensary in Boyle Heights. (Photo by Irfan Khan/Los Angeles Times via Getty Images) Vendors and growers prepare their displays for card-carrying medical marijuana patients attending Los Angeles' first-ever cannabis farmer's market at the West Coast Collective medical marijuana dispensary, on the fourth of July, or Independence Day, in Los Angeles, California on July 4, 2014 where organizer's of the 3-day event plan to showcase high quality cannabis from growers and vendors throughout the state. AFP PHOTO/Frederic J. BROWN (Photo credit should read FREDERIC J. BROWN/AFP/Getty Images) Containers of the medical marijuana product known as 'Wax' are displayed at Los Angeles' first-ever cannabis farmer's market at the West Coast Collective medical marijuana dispensary, on the fourth of July, or Independence Day, in Los Angeles, California on July 4, 2014 where organizer's of the 3-day event plan to showcase high quality cannabis from growers and vendors throughout the state. AFP PHOTO/Frederic J. BROWN (Photo credit should read FREDERIC J. BROWN/AFP/Getty Images) Up Next See Gallery Discover More Like This HIDE CAPTION SHOW CAPTION of SEE ALL BACK TO SLIDE

Though it still must go to a vote, the deal has the key backing of both the church and leaders of the Republican-dominated Legislature, who said the regulations in the hard-won agreement have their seal of approval. Unlike the ballot initiative, the compromise won't allow people to grow their own marijuana if they live too far from a dispensary. It also doesn't allow certain types of edible marijuana that could appeal to children, like cookies and brownies.

"I will do everything in my power to ensure this compromise passes in the special session," said Utah Senate president Wayne Niederhauser.

Medical marijuana advocates are backing the deal to avoid wrangling and uncertainty that could continue if the ballot initiative passes.

"There will be medical cannabis here in our day in Utah," said advocate DJ Schanz. The two sides agreed to scale back media campaigns supporting and opposing the ballot measure known as Proposition 2.

Not all medical-marijuana advocates were convinced: Christine Stenquist with the group Truce said she remains skeptical about the deal and urged continued support for the ballot proposal.

Smoking marijuana would not be allowed under the ballot proposal. It instead allows edible forms, lotions or electronic cigarettes.

While The Church of Jesus Christ of Latter-day Saints opposed the ballot measure, leaders also made first-ever public statement supporting the use of medical marijuana if prescribed by a doctor and dispensed by a pharmacy. The church's positions carry outsized sway in its home state.

The faith had long frowned upon medical marijuana use because of a key church health code called the "Word of Wisdom," which prohibits coffee as well as alcohol, tobacco and illegal drugs.

More from :

Michigan football team not allowed on-field prayer for coach's sick daughter

Cardinal hires judge to review church sex abuse policies

Vatican promises 'clarifications' to pope cover-up claims