Such a move would carry risks, said Richard Socarides, who was an adviser to President Bill Clinton on gay rights issues. “There will be an increasingly high price to pay politically for enforcing a law which 70 percent of the American people oppose and a core Democratic constituency abhors,” he said.

Critics of the ruling include Tony Perkins, the president of the Family Research Council and a proponent of the don’t ask, don’t tell law, who accused Judge Phillips of “playing politics with our national defense.”

In a statement, Mr. Perkins, a former Marine, said that “once again, an activist federal judge is using the military to advance a liberal social agenda,” and noted that there was still “strong opposition” to changing the law from military leaders.

Mr. Perkins predicted that the decision would have wide-ranging effects in the coming elections. “This move will only further the desire of voters to change Congress,” he said. “Americans are upset and want to change Congress and the face of government because of activist judges and arrogant politicians who will not listen to the convictions of most Americans and, as importantly, the Constitution’s limits on what the courts and Congress can and cannot do.”

The don’t ask, don’t tell law was originally proposed as a compromise measure to loosen military policies regarding homosexuality. Departing from a decades-old policy of banning service by gay, lesbian and bisexual recruits, the new law allowed service and prohibited superiors from asking about sexual orientation. But the law also held that service members could be dismissed from the military if they revealed their sexual orientation or engaged in homosexual acts.

Since 1993, some 14,000 gay men and lesbians have been discharged from the service when their sexual orientation became known, according to Mr. Nicholson’s group.

The law has long been a point of contention, and President Obama has asked Congress to repeal it.

At an afternoon briefing on Tuesday, the White House press secretary, Robert Gibbs, said the injunction was under review, but that “the president will continue to work as hard as he can to change the law that he believes is fundamentally unfair.”