President Joe Biden on Tuesday signed into law a bill that protects same-sex and interracial marriages.

The president signed the Respect for Marriage Act at an event on the South Lawn of the White House attended by thousands of guests.

“For most of our nation's history, we denied interracial couples and same-sex couples from these protections,” Biden said. “It failed to treat them with equal dignity and respect. And now, this law requires an interracial marriage and same-sex marriage must be recognized as legal in every state in the nation.”

The law repeals the Defense of Marriage Act (DOMA), which defined marriage for federal purposes as a heterosexual union. The Supreme Court struck down key provisions of DOMA in 2013. Biden voted for DOMA as a senator in 1996.

The Respect for Marriage Act also requires states to recognize all legal out-of-state marriages.

The bill cleared Congress with the help of 39 Republicans in the House and 12 Republicans in the Senate.

Democrats reintroduced the legislation in June after the Supreme Court overturned Roe v. Wade. Supporters of the measure pointed out that like Roe the decision that ushered in nationwide marriage equality was also based on the right to privacy.

Tuesday's bill signing came a decade after Biden unexpectedly declared his support for same-sex marriage.

“I am absolutely comfortable with the fact that men marrying men, women marrying women, and heterosexual men and women marrying another are entitled to the same exact rights, all the civil rights, all the civil liberties,” then-Vice President Biden said during an interview on NBC's Meet the Press.

Biden's comments prompted then-President Barack Obama to announce his support for marriage equality.

LGBTQ rights advocates cheered Tuesday's bill signing.

“Today is a historic day and a much-needed victory for our community,” Human Rights Campaign (HRC) President Kelley Robinson said in a statement. “It should be lost on no one that this bill signing comes less than a month after a deadly attack on our community in Colorado Springs, and at a time when the community continues to face ongoing threats of online and offline violence, as well as legislative attacks on our rights. In signing this bill, President Biden has shown that LGBTQ+ peoples’ lives and love are valid and supported.”