“Where American families are becoming more inclusive, I think the same is true of the L.D.S. faith,” he said. “We believe we should treat people with dignity, and you saw that on the immigration reform issue as well. It’s an issue of fairness.”

Success in the Senate guarantees nothing in the House, where the measure faces serious Republican resistance. Speaker John A. Boehner has made no commitment to put it to a vote, a prospect that drew criticism from President Obama after the Senate vote on Thursday. “One party in one house of Congress should not stand in the way of millions of Americans who want to go to work each day and simply be judged by the job they do,” the president said in hailing the Senate vote.

Building support among the Senate’s Mormons had always been part of the strategy for the bill’s sponsor, Senator Jeff Merkley, Democrat of Oregon, who reached out to the man he beat in 2008 — Mr. Smith — for help. “He can speak from a perspective that I might not be able to replicate,” Mr. Merkley said of his former rival. When Mr. Smith asked how he might help, Mr. Merkley suggested he reach out to Mr. Hatch.

Of all the Republican senators who came around to supporting the bill, Mr. Hatch was in some ways the least obvious. He is solidly conservative on social issues like abortion and same-sex marriage. He is one of the oldest members of the Senate. But Mr. Smith, who co-sponsored the hate crimes bill named for Matthew Shepard, said he appealed to Mr. Hatch’s “constructive conservatism.”

Shortly before the committee vote in July, he said he reminded Mr. Hatch about the church’s support for the Salt Lake City initiative and impressed on him that this was an issue of conscience. “These are positions that I came to as a matter of my own conscience long ago,” he said.