It will not change the policy right away; the judge called for the plaintiffs to submit a proposed injunction limiting the law by Sept. 16th. The defendants will submit their objections to the plan a week after that. Any decision would probably be stayed pending appeals.

The suit was brought by the Log Cabin Republicans, a gay organization. The group’s executive director, R. Clarke Cooper, pronounced himself “delighted” with the ruling, which he called “not just a win for Log Cabin Republican service members but all American service members.”

Those who would have preserved the rule were critical of the decision.

“It is hard to believe that a District Court-level judge in California knows more about what impacts military readiness than the service chiefs who are all on record saying the law on homosexuality in the military should not be changed,” said Tony Perkins, president of the Family Research Council, a conservative group. He called Judge Phillips, who was appointed by President Bill Clinton, a “judicial activist.”

As a candidate for president, Senator Barack Obama vowed to end “don’t ask, don’t tell.” Once elected, he remained critical of the policy but said it was the role of Congress to change the law; the Justice Department has continued to defend the law in court.

In February, Defense Secretary Robert M. Gates and Adm. Mike Mullen, the chairman of the Joint Chiefs of Staff, asked Congress to allow gays to serve openly by repealing the law. The House has voted for repeal, but the Senate has not yet acted.

Richard Socarides, a lawyer who served as an adviser to the Clinton administration on gay issues when the policy was passed into law, said the legal action was long overdue. “The president has said he opposes the policy, yet he has defended it in court. Now that he’s lost, and resoundingly so, he must stop enforcing it.”

The case, which was heard in July, involved testimony from six military officers who had been discharged because of the policy. One, Michael Almy, was an Air Force major who was serving his third tour of duty in Iraq when someone using his computer found at least one message to a man discussing homosexual conduct.