Senators on Tuesday passed legislation cementing federal protections for same-sex marriage, a historic step that follows months of bipartisan negotiations and puts the landmark bill just steps away from becoming law.

The Senate passed the Respect for Marriage Act in a 61-36 vote, with 12 Republicans joining forces with all Democrats present to advance the bill across the Capitol complex. The measure required 60 votes to pass.

The proposal would put into law protections for same-sex marriages that were initially handed down by the Supreme Court in Obergefell v. Hodges back in 2015 and that some feared could someday be in jeopardy after the high court overturned Roe v. Wade this summer.

“For millions and millions of Americans, today is a very good day. An important day. A day that’s been a long time coming,” Senate Majority Leader Charles Schumer (D-N.Y.) said on the Senate floor on Tuesday, noting he was sporting the tie he wore to his daughter’s wedding to her now-wife. “Sometimes we’ve taken steps forward. Other times, unfortunately, we’ve taken disturbing steps backward. But today … we are taking the momentous step forward for greater justice for LGBTQ Americans.”

The vote completes a winding path for the effort to codify same-sex marriage in the upper chamber. The legislative effort cropped up over the summer after Associate Justice Clarence Thomas opened the door to the idea of overturning Obergefell in a concurring opinion to the Dobbs v. Jackson Women’s Health Organization ruling that overturned Roe v. Wade. 

After the House passed the bill with the backing of 47 Republicans, Democrats in the upper chamber pushed to do the same before the midterm elections, but were unable to win the needed 10 votes from Senate Republicans. 

“Today, we have vindication the wait was well worth it,” Schumer said, referring to his decision to hold off voting on the bill until after the midterm elections. “Pushing Respect for Marriage over the finish line required patience, persistence, and today it is paying off.”

Headlining the concerns for Senate Republicans was the need for religious freedom protections, and language in an amendment to the bill  shields nonprofit religious organizations from having to providing services in support of same-sex marriages. 

The amendment also includes provisions related to religious liberty and conscience protections under the Constitution and federal law, and ensures the federal government does not recognize polygamous marriage.

A number of conservatives have argued for weeks the amendment didn’t go far enough to protect religious institutions and entities. Three separate amendments offered by Sens. Mike Lee (R-Utah), James Lankford (R-Okla.) and Marco Rubio (R-Fla.) aimed at expanding religious liberty provisions in the bill even further were voted down prior to the final passage vote. 

A bipartisan group of five senators leading the charge for the legislation — Tammy Baldwin (D-Wis.), Susan Collins (R-Maine), Rob Portman (R-Ohio), Kyrsten Sinema (D-Ariz.) and Thom Tillis (R-N.C.) — crafted the amendment that ultimately persuaded enough Republicans to support the broader bill. 

“We are not pushing this legislation to make history. We are doing this to make a difference for millions upon millions of Americans,” Baldwin, the lone senator who identifies as a lesbian, told reporters on Tuesday. “It’s a historic day, but it’s going to make a difference.” 

Sen. Cynthia Lummis (R-Wyo.), one of the key Republican votes for the bill, said in a floor speech Tuesday that the previous weeks “have involved a painful exercise in accepting admonishment and fairly brutal self-soul searching, entirely avoidable, I might add, if I had simply chosen to vote ‘no.'”

She concluded her speech that, “For the sake of our nation today and its survival, we do well by taking this step. Not embracing or validating each other’s devoutly held views, but by the simple act of tolerating them. And that … explains my vote.” 

Structurally, the bill would repeal the Defense of Marriage Act, which passed overwhelmingly in 1996 and defined marriage as only between a man and a woman. A number of states still have laws on the books banning same-sex marriage and codifying the legislation for same-sex couples means that even if the Supreme Court were to overturn protections, their marriages would be recognized across the country.

The legislation also cements protections for interracial couples because current federal law is silent on the issue of interstate interracial marriages. 

The bill now heads to the House for a second time because of the religious freedom amendment. House Majority Leader Steny Hoyer (D-Md.) indicated on Tuesday that the lawmakers will vote on it “as soon as Tuesday” of next week. 

That would send the blueprint to President Biden for his signature.