The US Congress on Thursday passed landmark legislation to protect same-sex marriage under federal law, and President Joe Biden has vowed to quickly sign the measure.
The vote in the House of Representatives saw 39 Republicans join a united Democratic majority in a rare show of bipartisanship, provoking loud cheers on the floor less than 10 days after the Senate passed the same bill.
"Today this chamber proudly stands with the forces of freedom," outgoing House Democratic Speaker Nancy Pelosi said shortly before the vote.
The conservative-led Supreme Court in June had overturned longstanding abortion rights, prompting lawmakers of both parties to move quickly to prevent the court from taking away same-sex marriage rights, as some feared it might do.
The House, which had earlier approved similar legislation, needed Thursday's vote to reconcile minor differences with the Senate's version.
Also read: Pope Francis breaks down, cries while mentioning Ukraine at public prayer
Biden has dubbed marriage equality one of his legislative priorities and has said he will "promptly and proudly" sign the bill into law.
Democrats and others saluted the historic vote.
"I began my career fighting for LGBTQ communities," Pelosi tweeted on Thursday, "and now, one of the final bills that I will sign as Speaker will ensure the federal government never again stands in the way of marrying the person you love."
The new legislation, known as the Respect for Marriage Act, does not require states to legalize same-sex marriage but does require them to recognize a marriage so long as it was valid in the state where it was performed.
It repeals previous legislation defining marriage as a union between a man and a woman, and also protects interracial couples by requiring states to recognize legal marriages without regard to "sex, race, ethnicity or national origin."
Public acceptance of same-sex marriage has grown dramatically in recent decades, with polls now showing a strong majority of Americans supporting it.
Also read: Putin says strikes on Ukraine's energy infrastructure 'response to Kyiv's actions'
But some conservatives and the religious right remain opposed.
"I think this is the wrong way to go," conservative Republican Jim Jordan said shortly before the vote.
House Democrats had worked with urgency to get the bill passed while they still control Congress. Republicans won a narrow majority in the chamber in midterm elections in November and will take control there in January, while Democrats retain narrow control of the Senate.
The Supreme Court in a 2015 decision legalized same-sex marriages. Hundreds of thousands of couples have married since then.