WASHINGTON  A federal judge in California said Wednesday that the wiretapping law established by Congress was the “exclusive” means for the president to eavesdrop on Americans, and he rejected the government’s claim that the president’s constitutional authority as commander in chief trumped that law.

The judge, Vaughn R. Walker, the chief judge for the Northern District of California, made his findings in a ruling on a lawsuit brought by an Oregon charity. The group says it has evidence of an illegal wiretap used against it by the National Security Agency under the secret surveillance program established by President Bush after the terrorist attacks of Sept. 11, 2001.

The Justice Department has tried for more than two years to kill the lawsuit, saying any surveillance of the charity or other entities was a “state secret” and citing the president’s constitutional power as commander in chief to order wiretaps without a warrant from a court under the agency’s program.

But Judge Walker, who was appointed to the bench by former President George Bush, rejected those central claims in his 56-page ruling. He said the rules for surveillance were clearly established by Congress in 1978 under the Foreign Intelligence Surveillance Act, which requires the government to get a warrant from a secret court.