SALT LAKE CITY (AP) — Episcopalians voted overwhelmingly Wednesday to allow religious weddings for same-sex couples, solidifying the church’s embrace of gay rights that began more than a decade ago with the pioneering election of the first openly gay bishop.

The vote came in Salt Lake City at the Episcopal General Convention, just days after the U.S. Supreme Court legalized gay marriage nationwide. It passed in the House of Deputies, the voting body of clergy and lay participants at the meeting. The House of Bishops had approved the resolution Tuesday by 129-26 with five abstaining.

The Rev. Brian Baker of Sacramento said the church rule change was the result of a nearly four-decade long conversation that has been difficult and painful for many. Baker, chair of the committee that crafted the changes, said church members have not always been kind to one another but that the dynamic has changed in recent decades.

“We have learned to not only care for, but care about one other,” Baker said. “That mutual care was present in the conversations we had. Some people disagreed, some people disagreed deeply, but we prayed and we listened and we came up with compromises that we believe make room and leave no one behind.”

Baker said the House of Bishops prayed and debated the issue for five hours earlier this week before passing it on to the House of Deputies.

The Rev. Bonnie Perry of Chicago, a lesbian married to a fellow Episcopal priest, hugged fellow supporters on Wednesday and said, “We’re all included now.”

“For the lesbian, gay, bisexual and transgender people in our congregations now know under the eyes of God and in every single state in this blessed country, they are welcome to receive all the sacraments,” she said.

The Rev. Jose Luis Mendoza-Barahona of Honduras gave an impassioned speech, saying the new church law goes against the Bible and would create a chasm in the church.

“The fight has not ended, it’s starting,” he said. “Those of us in the church who are loyal followers of Christ are going to remain firm in not recognizing what happened today.”

The vote eliminates gender-specific language from church laws on marriage so that same-sex couples could have religious weddings. Instead of “husband” and “wife,” for example, the new church law will refer to “the couple.” Under the new rules, clergy can decline to perform the ceremonies. The changes were approved 173-27. The deputies also approved a gender-neutral prayer service for marriage on a 184-23 vote.

The measures take effect the first Sunday of Advent, Nov. 29.

Many dioceses in the New York-based church of nearly 1.9 million members have allowed their priests to perform civil same-sex weddings, using a trial prayer service to bless the couple. Still, the church hadn’t changed its own laws on marriage until Wednesday.

The Episcopal Church joins two other mainline Protestant groups that allowed gay marriage in all their congregations: the United Church of Christ and the Presbyterian Church (U.S.A.). The 3.8-million-member Evangelical Lutheran Church in America lets its congregations decide for themselves, and many of them host gay weddings.

The United Methodist Church, by far the largest mainline Protestant church with 12.8 million members, bars gay marriage, although many of its clergy have been officiating at same-sex weddings recently in protest.

The Episcopal Church is the U.S. wing of the Anglican Communion, an 80 million-member global fellowship of churches. Ties among Anglicans have been strained since Episcopalians in 2003 elected Bishop Gene Robinson, who lived openly with his male partner, to lead the Diocese of New Hampshire. Many theologically conservative Episcopalians either split off or distanced themselves from the national U.S. church after Robinson’s election.

On the eve of Wednesday’s vote, Archbishop of Canterbury Justin Welby, spiritual leader of the world’s Anglicans, issued a statement expressing deep concern about the move to change the definition of marriage.

Robinson said after the vote, “It’s a day I wasn’t sure I would live to see.”

“What we’re seeing I think in the Episcopal Church, and last week with the Supreme Court decision, is an entire culture evolving into understanding that gay and lesbian, bisexual and transgender people contribute just as much as anyone else to this society and deserve all the same rights,” Robinson said.

After the Supreme Court ruling last week, many conservative churches, including the Southern Baptist Convention and the Mormons, renewed their opposition to gay marriage.

The gay marriage decision is the second major news to come from the convention, the top policymaking body of the church. The church elected its first black presiding bishop last weekend, with Bishop Michael Curry of North Carolina winning in a landslide.

Curry has allowed same-sex church weddings in North Carolina, and he said the Supreme Court “affirmed the authenticity of love” by legalizing gay marriage.