And as the bill approached a vital vote earlier this week, Senator Dean Heller, the Nevada Republican who has taught Sunday school at his Mormon church, provided the crucial 60th vote to break a filibuster.

In the end, all but two of the Senate’s seven Mormons voted yes.

Their support for including civil rights protections for gay, lesbian, bisexual and transgender people is the latest example of a broader evolution by some of the most visible members of the Church of Jesus Christ of Latter-day Saints, who have come to cautiously embrace gay rights. It is a remarkable turnabout from just five years ago, when the church faced a maelstrom of criticism for backing the initiative in California that took away the right of same-sex couples to marry.

Unlike the issue of marriage, which the church views as an inviolable doctrine, nondiscrimination law has become one subject that Mormons of all political stripes can safely seem to support. Indeed, the church publicly backed a provision in Salt Lake City in 2009 that extended many of the same workplace protections as the Senate bill. It did not, however, take a public position during the Senate debate.

The church has also embarked on a public relations campaign to soften the perception that it is homophobic. It has even created a website called MormonsandGays.org, which points out that while acting on same-sex attraction is a sin, “With love and understanding, the Church reaches out to all God’s children, including our gay and lesbian brothers and sisters.”

Mr. Heller, who voted against a similar nondiscrimination measure in 2007 when he was a member of the House, said he was typical of members of his faith who had come around on the issue.