The ruling, by 5-4 vote, was described as a historic step by President Barack Obama.
Justice Anthony Kennedy said that the Defence of Marriage Act (DOMA) "violates basic due process and equal protection principles applicable" to the federal government.
"The majority opinion also criticises DOMA as an intrusion on states' traditional role defining marriage," he wrote.
"DOMA undermines both the public and private significance of state-sanctioned same-sex marriages; for it tells those couples, and all the world, that their otherwise valid marriages are unworthy of federal recognition," Kennedy wrote in his judgement.
