The U.S. House of Representatives gave final approval Thursday to a bill that protects same-sex and interracial marriages.

The measure, which passed 258-169, now heads to President Joe Biden’s desk to be signed into law.

The legislation repeals the 1996 Defense of Marriage Act that defines marriage as between a man and a woman under federal law. It would also require states to recognize same-sex and interracial marriages performed in other states, although it does not prevent states from passing laws banning those marriages.

The U.S. Supreme Court legalized same-sex marriage at the federal level in its 2015 Obergefell v. Hodges decision. But the court’s Dobbs v. Jackson decision in June overturning a right to abortion at the federal level raised concerns about federal protections for other rights.

In his concurring opinion in Dobbs v. Jackson, Justice Clarence Thomas wrote the court should reconsider other decisions based on the right to privacy, such as guarantees for the right to marry or the right to use birth control, arguing the U.S. Constitution does not guarantee those rights. Thomas’ opinion led to widespread concern the court would next move to overturn the right to same-sex marriage. A bipartisan group of senators worked on the Respect for Marriage Act to address this possibility.

After the recent Senate approval of the legislation, Republican Senator Mike Lee said on the Senate floor during debate that this legislation was unnecessary.

“A single line from a single concurring opinion does not make the case for legislation that seriously threatens religious liberty. The Respect for Marriage Act is unnecessary. States are not denying recognition of same-sex marriage. And there’s no serious risk of anyone losing recognition,” he said.

The legislation had passed the U.S. House of Representatives earlier this year with support from 47 Republicans. It headed back to the House so that members could vote on religious liberty protection amendments added in the Senate.

Liberty Counsel, a nonprofit organization advancing religious freedom, said in a statement that the Respect for Marriage Act was unconstitutional and does not provide “any protection for religious individuals or organizations, and the subsequent amendments to the bill exclude a large percentage of constitutionally and statutorily protected religious organizations.”

But Republican Senator Susan Collins, another co-sponsor of the legislation, said on the Senate floor that concerns about religious liberty were a false argument.

“This legislation would make clear in federal law that nonprofit religious organizations and religious educational institutions cannot be compelled to participate in or support the solicitation or celebration of marriages that are contrary to their religious beliefs,” she said.

In a May 2022 Gallup poll, 71% of Americans said they support same-sex marriage. Only 27% supported it when the poll was first taken in 1996.