In a historic decision, the Supreme Court ruled on Wednesday that the federal Defense of Marriage Act is unconstitutional.

By a tight 5-4 vote, the court struck down the law, which since 1996 has barred the federal government from legally recognizing and extending benefits to same-sex couples.

"DOMA singles out a class of persons deemed by a State entitled to recognition and protection to enhance their own liberty," the court wrote in the majority opinion.

Justice Anthony Kennedy joined Justices Kagan, Sotomayor, Ginsburg, and Breyer in voting to strike down the law. Chief Justice John Roberts, as well as Justices Alito, Thomas, and Scalia voted against.

In a sweeping ruling, the court said that the federal government could no longer discriminate against same-sex couples. In his majority opinion, Kennedy framed the issue as one of liberty and equality, saying that to deny same-sex couples equal protection under the law was a violation of the Fifth Amendment.

"The power the Constitution grants it also restrains," Kennedy wrote. "And though Congress has great authority to design laws to fit its own conception of sound national policy, it cannot deny the liberty protected by the Due Process Clause of the Fifth Amendment."

This is a huge victory for gay rights activists, and in particular for Edith Windsor, the New York woman who brought the initial lawsuit that challenged DOMA's constitutionality.

Windsor, who challenged the federal government's refusal to recognize her 42-year marriage to her late wife, Thea Spyer, celebrated outside the Supreme Court Wednesday.

President Barack Obama's administration announced in 2011 that it would no longer defend DOMA in court. That prompted House Republicans to mount their own legal defense.

Following the ruling, Obama tweeted his support for the decision.

In a scathing dissent, Scalia blasted his fellow justices, accusing them of judicial activism and suggesting the court had no grounds to hear the case in the first place.

"We have no power to decide this case," he wrote. "And even if we did, we have no power under the Constitution to invalidate this democratically adopted legislation. The Court's errors on both points spring forth from the same diseased root: an exalted conception of the role of this institution in America."

Read the entire ruling below:

Doma Decision