Since taking office, President Obama has rarely walked as fine a line in balancing allegiance to competing interests as he has with the Defense of Marriage Act, or DOMA, which defines marriage as between a man and a woman.
On the campaign trail and as president, Obama has called the law "abhorrent" and urged a legislative repeal. At the same time, his administration has defended the law in federal courts, fending off legal challenges brought by gay and lesbian groups Obama has tried to woo.
The awkward dance reached a new stage Thursday when a U.S. District Court judge in Massachusetts ruled against the administration and DOMA, calling it an unconstitutional infringement on states' rights to define marriage and award benefits of such federal-state programs as Medicaid.
The act "plainly encroaches" on the right of the state to determine marriage, Judge Joseph Tauro wrote. "Congress undertook this classification for the one purpose that lies entirely outside of legislative bounds, to disadvantage a group of which it disapproves. And such a classification the Constitution clearly will not permit."
While Tauro's decision applies only to Massachusetts, its impact could spread if it's allowed to stand, legal experts said. Other state attorneys general who oppose DOMA could file similar cases to challenge the law.
The question now for the Obama administration is whether to appeal.
Justice Department spokeswoman Tracy Schmaler said that the administration was "reviewing the decision" and had not yet decided whether to further defend the law in court.
But when the department first filed court briefs in support of DOMA last year, Schmaler explained that "until Congress passes legislation repealing the law, the administration will continue to defend the statute when it is challenged in the justice system."
Joe Solomonese, president of Human Rights Campaign, acknowledged the Justice Department would likely continue to defend DOMA on appeal. But, he said, Obama must simultaneously push Congress to repeal the law.
"Judge Tauro's decisions make clear that there is no constitutional justification for DOMA, despite the Department of Justice's contentions in defending the statute," Solomonese said. Its a law "that we know, and Judge Tauro recognized, serves no purpose but to denigrate our families."
Meanwhile, the conservative Family Research Council criticized Tauro's decision and what it called "the deliberately weak legal defense of DOMA" that the Justice Department mounted.
Obama Changed Stance on DOMA in 2004
The case began in March 2009 when the group Gay and Lesbian Advocates and Defenders filed a suit against the Obama administration's Office of Personnel Management on behalf of eight married gay couples and three surviving spouses who were denied federal spousal rights and benefits because of DOMA.
The law defines marriage as "only a legal union between one man and one woman as husband and wife, and the word 'spouse' refers only to a person of the opposite sex who is a husband or a wife." The federal government does not recognize marriages of any other kind.
DOMA was passed by Congress and signed into law by President Clinton in 1996 after some states and gay marriage opponents worried that they would be forced to recognize same-sex unions performed in other states.
While campaigning for the Illinois U.S. Senate sear in 2004, Obama expressed support for DOMA, telling a group called Independent Voters of Illinois -- Independent Precinct Organization that he favored the law.
He later switched to an anti-DOMA position on Feb. 11, 2004, as the Illinois Democratic primary drew near. According to Obama's staff at the time, Obama changed positions mid-campaign because he heard from gay friends about how hurtful DOMA was.
As a candidate for president, Obama said DOMA was "was an unnecessary imposition on what had been the traditional rules governing marriage and how states interact on the issues of marriage." His campaign website stated that he supported the complete repeal of DOMA.
"Federal law should not discriminate in any way against gay and lesbian couples," he said, "which is precisely what DOMA does."
Five states -- Massachusetts, Iowa, Connecticut , Vermont and New Hampshire -- and the District of Columbia currently perform same-sex marriages. Four states recognize marriages performed elsewhere, and nine states grant civil unions or partnerships.
ABC News' Jake Tapper contributed to this report.