Attorneys for conservative groups hailed the ruling by U.S. District Judge James S. Moody as an important first step, but the plaintiffs promised to appeal.
Although several federal cases are challenging the 1996 Defense of Marriage Act, attorneys said yesterday's ruling was the first by a federal judge on a direct challenge to the law.
Moody sided with former Attorney General John Ashcroft, who argued in court filings that the government has a legitimate interest in allowing states to ban same-sex marriages, namely to encourage "stable relationships" for the rearing of children by both biological parents.
The Justice Department did not immediately comment on the ruling.
The plaintiffs, Nancy Wilson and Paula Schoenwether, a couple for 27 years who live in Tampa, were married in Massachusetts in July. They wanted their union recognized in Florida, where state law specifically bans same-sex marriages.
The women argued that the Defense of Marriage Act was unconstitutional because it was discriminatory on the basis of sex and violated their fundamental rights.
Moody said he could not declare marriage a "fundamental right," as the lawsuit urged him to do, and that he was bound to follow legal precedent.
"The legislatures of individual states may decide to overturn its precedent and strike down" the law, Moody wrote. "But, until then, this court is constrained to hold [the law] and the Florida statutes ... constitutionally valid."
Wilson, a minister for Metropolitan Community Churches, one of the world's largest congregations of gay Christians, said in a statement that she was prepared to take her challenge to the Supreme Court.
"Despite this ruling, we are still married in our hearts, and legally married in Massachusetts," she said. Her partner added: "No civil rights movement was lost on one bad court decision."
Conservative Christian groups applauded the ruling.
"Today we have witnessed a significant victory - for marriage and democracy," said Tom Minnery of Focus on the Family, which is pushing for a constitutional amendment that would ban same-sex marriages.
"Unfortunately, at any time, marriage in any jurisdiction is only one judge away from being ruled unconstitutional," he said.
Last year, a federal bankruptcy judge in Washington state ruled the Defense of Marriage Act constitutional when a lesbian couple sought to file for bankruptcy as a heterosexual couple would. But that decision was not binding on other courts.
State ruling reversed