With the backing of Mormon church leaders, the Republican-dominated Utah Legislature passed a bill on Wednesday night that would ban discrimination against lesbian, gay, bisexual and transgender people in housing and employment, while also protecting religious institutions that object to homosexuality.

The legislation, known as “the Utah compromise,” has been hailed by Mormon leaders and gay rights advocates as a breakthrough in balancing rights and religious freedom, and as a model for other conservative states. But leaders of some other churches oppose it, saying it would not sufficiently protect the rights of individuals who have religious objections to homosexuality.

The vote was an extraordinary moment for the Church of Jesus Christ of Latter-day Saints, which is opposed to same-sex marriage, but sent two of its leading apostles to a news conference on Capitol Hill in Salt Lake City last week to endorse the anti-discrimination bill. Legislators and gay rights advocates said having the blessing of the church leaders turned the tide in the Legislature, where most members are Mormons.

“The apostles of this faith, which is the predominant faith here in Utah, stepped forward and expressed an earnest and sincere desire to come together,” said Representative Gregory H. Hughes, a Republican and the speaker of the Utah House. “We had not heard that before, and we had not heard that with such specificity, and we took notice.”