By DENISE LAVOIE

AP Legal Affairs Writer

BOSTON — A U.S. judge in Boston has ruled that a federal gay marriage ban is unconstitutional because it interferes with the right of a state to define marriage.

U.S. District Judge Joseph Tauro on Thursday ruled in favor of gay couples' rights in two separate challenges to the 1996 Defense of Marriage Act, known as DOMA.

The state had argued the law denied benefits such as Medicaid to gay married couples in Massachusetts, where same-sex unions have been legal since 2004.

Tauro agreed, and said the act forces Massachusetts to discriminate against its own citizens.

"The federal government, by enacting and enforcing DOMA, plainly encroaches upon the firmly entrenched province of the state, and in doing so, offends the Tenth Amendment. For that reason, the statute is invalid," Tauro wrote in a ruling in a lawsuit filed by Attorney General Martha Coakley.

Ruling in a separate case filed by Gays & Lesbian Advocates & Defenders, Tauro found that DOMA violates the equal protection clause of the U.S. Constitution.

"We've maintained from the very beginning that there was absolutely no basis for this law treating one class of married Massachusetts couples different from everybody else and the court has recognized that," said Gary Buseck, GLAD's legal director.

The Justice Department argued the federal government has the right to set eligibility requirements for federal benefits — including requiring that those benefits only go to couples in marriages between a man and a woman.

The law was enacted by Congress in 1996 when it appeared Hawaii would soon legalize same-sex marriage and opponents worried that other states would be forced to recognize such marriages. The lawsuit challenges only the portion of the law that prevents the federal government from affording pension and other benefits to same-sex couples.

Since then, five states and the District of Columbia have legalized gay marriage.