The bill will give "millions of same sex and interracial couples the confidence and certainty that they need that their marriages are and will in the future continue to be valid," Democratic Senator Tammy Baldwin, one of the lead negotiators on the bill, said ahead of the bill's passage on Tuesday.
Baldwin is the first openly gay person elected to the U.S. Senate.
A similar, but not identical, bill passed the House of Representatives earlier this year with support from 47 Republicans and all Democrats. The House would need to approve the Senate version before it is sent to President Joe Biden to sign into law.
No. 2 House Democrat Steny Hoyer told reporters on Tuesday the House would likely take up the Senate's version of the bill next week.
In June, the Supreme Court overturned the nationwide right to an abortion, undoing 50 years of precedent.
In a concurring opinion, Supreme Court Justice Clarence Thomas wrote the court should consider reversing other decisions protecting individual freedoms, including the 2015 ruling on gay marriage.
About 568,000 married same-sex couples live in the United States, according to the U.S. Census Bureau.