Salt Lake City legislation giving gays and lesbians protection from discrimination was supported by the Mormon Church, which traditionally rails against equal rights measures.

Lawmakers voted last night to protect gays, lesbians and trans people from discrimination in employment and housing.

According to the Salt Lake Tribune, the legislation was passed unanimously and makes Salt Lake City the first Utah district to prohibit bias based on sexual orientation or gender identity.

There are some caveats, however. The legislation has been drafted to allow churches to abide by their religious principles and religion-based rules without facing penalties.

The Church of Jesus Christ of Latter-day Saints is one of the most vociferous opponents of gay marriage in the US and pumped millions of dollars into the campaign to ban gay marriage in California last year.

However, Michael Otterson, the director of public affairs for the Church of Jesus Christ of Latter-day Saints said: “The church supports these ordinances because they are fair and reasonable and do not do violence to the institution of marriage.”

He added that the church had not changed its position on gay marriage and “remains unequivocally committed to defending the bedrock foundation of marriage between a man and a woman”.