WASHINGTON — The Supreme Court struck down a key part of the federal Defense of Marriage Act on Wednesday and declared that same-sex couples who are legally married deserve equal rights to the benefits under federal law that go to all other married couples.

The decision is a landmark win for the gay rights movement. It voids a section of the law known as DOMA, which was adopted with bipartisan support in Congress in 1996 to deny all benefits and recognition to same-sex couples.

At that time, no state permitted gays and lesbians to marry. Now, 12 states and the District of Columbia authorize same-sex marriages.

Justice Anthony Kennedy, speaking for the 5-4 majority, said DOMA was unconstitutional because it violated the right to liberty and to equal protection for gay couples.

“By seeking to displace this protection and treating those persons as living in marriages less respected than others, the federal statute” violates the Constitution, he said.

The ruling means that more than 100,000 gay and lesbian couples who are legally married will be able to take advantage of tax breaks, pension rights and other benefits that are available to other married couples.