The bill was passed 61 to 36, with 60 votes needed for passage. Twelve Republicans joined 49 Democrats in supporting the bill. One Democrat, Georgia's Raphael Warnock, was absent, as were two Republican senators.
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.