A federal judge in Boston on Thursday ruled a key element of the Defense of Marriage Act unconstitutional, saying it violated the Equal Protection Clause and interfered with a state’s right to define marriage.

Gay rights advocates hailed the rulings as important steps toward striking down the law, which they say discriminates against their sexual orientation. Opponents denounced the decisions as judicial activism.

The 1996 law prohibits the federal government from recognizing same-sex marriages, which deprives gay spouses of federal benefits like healthcare and tax breaks that their heterosexual counterparts receive.

In two separate cases, plaintiffs argued that the law unfairly discriminated against gay spouses, even in states where their marriages are legal.

The rulings by U.S. District Judge Joseph Tauro deal only with the law as it affects Massachusetts residents. But they could eventually help secure federal benefits for other gay spouses in states where such marriages are legal, as well as for the estimated 16,000 gay couples who wed in California in 2008.

Massachusetts Atty. Gen. Martha Coakley had argued in a lawsuit that the law, known as DOMA, was forcing her state to discriminate against its own citizens.

Tauro agreed, saying the act “plainly encroaches” on a state’s right to define marriage.

“Today’s landmark decision is an important step toward achieving equality for all married couples in Massachusetts and assuring that all of our citizens enjoy the same rights and protections under our Constitution,” Coakley said. “It is unconstitutional for the federal government to discriminate, as it does because of DOMA’s restrictive definition of marriage.”

Separately, Gay & Lesbian Advocates & Defenders, or GLAD, had sued on behalf of seven same-sex couples and three widowers denied federal benefits because of their sexual orientation. Tauro said the law violated the Constitution in withholding insurance, pension and other benefits available to spouses of heterosexual couples.

“Today the court simply affirmed that our country won’t tolerate second-class marriages,” said Mary Bonauto, GLAD’s Civil Rights Project director, who argued the case. “I’m pleased that Judge Tauro recognized that married same-sex couples and surviving spouses have been seriously harmed by DOMA and that the plaintiffs deserve the same opportunities to care and provide for each other and for their children that other families enjoy.”

Kris Mineau, president of the Massachusetts Family Institute, which opposes gay marriage, condemned Tauro’s rulings, calling them “another blatant example of a judge playing legislator.”

Same-sex marriage activists have failed to win public approval of their “agenda,” Mineau said. “That is why their strategy is to force same-sex marriage through judicial fiat.”

A spokeswoman for the Justice Department said the government was studying the rulings. Atty. Gen. Eric H. Holder Jr. has criticized the marriage act as violating the civil rights of same-sex couples, but defended the statute as the prevailing law of the land until Congress repeals it. The government has 60 days to appeal Tauro’s ruling.

The lawsuits targeted Section 3 of the Defense of Marriage Act, which prohibits the government from recognizing same-sex unions in any way that costs the federal government money.

Gays have been eligible to marry in Massachusetts since 2004, and four other states and the District of Columbia have legalized same-sex marriage since then. The California Supreme Court struck down a ban on same-sex marriage in April 2008, allowing gay couples to begin marrying a month later.

But a citizen initiative on the November 2008 ballot, Proposition 8, defined marriage as exclusively between one man and one woman. The ban, passed by a 52% margin, is now before a federal judge in San Francisco on a similar challenge to its constitutionality.

Federal employees in same-sex marriages in California have previously won similar judgments saying that the government had to pay benefits to their spouses. Those cases were brought through an administrative process, rather than through lawsuits, because they involved Justice Department employees who are contractually prohibited from suing the government.

carol.williams@latimes.com