
The Respect for Marriage Act was approved in the Democratic-controlled chamber by a vote of 267 to 157, but its prospects are uncertain in the Senate.
47 Republican lawmakers joined Democrats in voting for the bill, which was met with scattered applause on the House floor when it passed.
Democrats have 50 seats in the 100-member Senate and 10 Republican votes would be needed to bring the measure to the floor.
The Respect for Marriage Act would force US states to recognise a valid marriage performed in another state, providing protection for not only same-sex unions but also interracial marriages.
The bill repeals the 1996 Defense of Marriage Act that defined a marriage as a union between one man and one woman.
The Supreme Court, in a 5-4 ruling, struck down part of the Defense of Marriage Act, which denied federal benefits to married same-sex couples, in 2013 but the law had remained on the books.
“The bipartisan Respect for Marriage Act will enshrine and protect marriage equality and make sure legal, same-sex and interracial marriages are recognised,” said senator Tammy Baldwin of Wisconsin.
The Supreme Court overturned Roe v Wade, the 1973 ruling enshrining nationwide abortion rights, on June 24, sparking forecasts that conservative justices could revisit other landmark decisions.
Same-sex marriage remains a high-value target for some Republicans and the religious right in the US, although 71% of Americans in a Gallup poll in May said they support such relationships.
By bringing the Respect for Marriage Act to a vote in the House, Democrats forced Republicans to go on the record on the issue ahead of the November midterm elections.
Clarence Thomas, one of the most conservative justices on the court, in his concurring opinion overturning abortion rights, ignited fears that other progressive gains could also be in danger.
Thomas argued that the court should also examine its ruling