The House on Thursday passed a bill to safeguard marriage equality, sending the measure to President Biden’s desk and marking the first time Congress has provided federal protections for same-sex marriage.

The legislation, titled the Respect for Marriage Act, passed in a 258-169-1 vote. Thirty-nine Republicans joined all Democrats in supporting the measure, and Rep. Burgess Owens (R-Utah) was the only lawmaker to vote present.

The Senate approved the measure in a bipartisan 61-36 vote last week, notching a significant win for negotiators after months of talks that followed Justice Clarence Thomas floating the idea of overturning the Supreme Court decision protecting same-sex marriage.

Twelve Senate Republicans joined all voting Democrats to pass the bill.

Following the bill’s passage in the Senate, Biden said he would “promptly and proudly” sign it into law once it arrived on his desk. He is expected to have a signing ceremony with lawmakers.

The measure enshrines federal protections for same-sex couples, requiring that the federal government and all states recognize marriages if the pair was wed in a state where the union was legal. It also cements protections for interracial couples, ordering states to recognize marriages regardless of “the sex, race, ethnicity, or national origin of those individuals.”

Additionally, the measure repeals the Defense of Marriage Act, a 1996 law that recognizes marriage as “only a legal union between one man and one woman as husband and wife” and refers to the word spouse as “a person of the opposite sex who is a husband or wife.”

The legislation approved by both chambers also includes an amendment outlining protections for religious liberties — an eleventh-hour addition that was central to securing enough Republican support for the bill’s passage in the Senate.

The House had passed the Respect for Marriage Act in a bipartisan 267-157 vote in July, with 47 Republicans joining all Democrats.

But Senate Republicans raised concerns about the lack of religious freedom protections in the measure, which led to bipartisan talks within the chamber to break the impasse and, last month, strike a deal on an amendment. The addition shields religious organizations from having to provide services supporting same-sex marriage, ensures that the federal government does not acknowledge polygamous marriage and includes conscience protections under the Constitution and federal law.

The addition of the amendment required the House to take up the measure again on Thursday.

Its passage marked a significant moment for Speaker Nancy Pelosi (D-Calif.), who is stepping down as Democratic leader at the end of this Congress. During a ceremony after the chamber cleared the legislation, Pelosi said she was pleased that one of the final bills she would oversee as Speaker is the marriage equality measure.

“You can just imagine how exciting it is, at this point at the end of this term as Speaker, to be signing the Respect for Marriage Act,” she said. Senate Majority Leader Charles Schumer (D-N.Y.) and Sens. Tammy Baldwin (D-Wis.) and Susan Collins (R-Maine) joined Democratic House members for the ceremony.

Former Rep. Barney Frank (D-Mass.), who was one of the first openly gay people to serve in Congress, also attended the ceremony following House passage.

“I was here for the birth of DOMA, so I am very grateful to be able to be here for the funeral,” he said.

The push for a bill protecting marriage equality on the federal level began in earnest over the summer after the Supreme Court struck down Roe v. Wade, the almost 50-year-old abortion rights decision. In a concurring opinion to that ruling, Thomas called on the court to reconsider Obergefell v. Hodges, the 2015 decision that enshrined same-sex marriage as a constitutional right.

Thomas’s statement — and seeing a landmark case overturned — set off alarm bells among Democrats that LGBTQ rights were in danger.

The Respect for Marriage Act would require that states recognize same-sex marriages if the court were to overturn Obergefell, which would return the issue to the states. It does not, however, go as far as to mandate that states perform those marriages, which is required in the Supreme Court ruling.

Lawmakers referenced that concern during debate on the House floor Thursday.

“Today we will vote for equality and against discrimination by finally overturning the exclusionary, homophobic Defense of Marriage Act and guaranteeing crucial protections for same-sex and interracial marriages,” Rep. David Cicilline (D-R.I.), a co-chair of the LGBTQ+ Equality Caucus, said.

“By passing the Respect for Marriage Act we will ensure that all Americans continue to be afforded the same rights by the government, no matter what the Supreme Court may decide in the future,” he added.

Some members spoke about how the measure would affect them personally.

“Thanks to bipartisan work in the Senate, the Respect for Marriage Act comes back to the House with added language that should allay anyone’s fears or misunderstandings, yet still ensure we can legally recognize marriage as it is currently recognized in this country,” Rep. Mark Pocan (D-Wis.), another co-chair of the LGBTQ+ Equality Caucus, said on the House floor. “It would be wrong to say my husband Phil and I have a marriage that is any different than anyone else’s marriage here in this body.”

Not all Republicans, however, were won over with the religious liberty amendment.

“I rise today in strong opposition to the so-called Respect for Marriage Act — honestly the bill should be called the ‘Disrespect for Marriage Act,’” Rep. Bob Good (R-Va.) said on the House floor during debate. “This bill certainly disregards God’s definition of marriage, a definition that has served his creation well for more than 5,000 years of recorded history.”

“And his definition is the only one that really matters,” he added.

Good, who was first elected to the House in 2020, beat former Rep. Denver Riggleman (R-Va.) in a GOP primary that year after Riggleman became the target of criticism for officiating a same-sex wedding.

Rep. Vicky Hartzler (R-Mo.) called the addition a “flimsy” and “hollow” amendment in a floor speech that brought her to the brink of tears.

Other Republicans disagreed with the argument that LGBTQ rights were in danger.

“Democrats have conjured up this nonexistent threat based on one line in Justice Thomas’s concurrence in Dobbs. And they are misunderstanding, or they are deliberately misrepresenting, what Justice Thomas wrote,” Rep. Jim Jordan (Ohio), the top Republican on the House Judiciary Committee, said during debate.

“Justice Thomas made the same point that he’s made for years: that the collection of rights secured by the doctrine of substantive due process is better understood as being a function of the Constitution’s Privileges and Immunities Clause. That’s it,” he added.

House and Senate passage of the bill came shortly after five people were killed in a shooting at an LGBTQ nightclub in Colorado Springs, Colo.

—Brett Samuels contributed. Updated at 5:30 p.m.