U.S. District Judge Anna Diggs Taylor in Detroit is the first judge to rule on the legality of the National Security Agency's program, which the White House says is a key tool for fighting terrorism that has already stopped attacks.
"Plaintiffs have prevailed, and the public interest is clear, in this matter. It is the upholding of our Constitution," Taylor wrote in her 43-page opinion.
The administration said it would appeal to the 6th U.S. Circuit Court of Appeals in Cincinnati.
"We're going to do everything we can do in the courts to allow this program to continue," Attorney General Alberto Gonzales said at a news conference in Washington.
White House press secretary Tony Snow said the Bush administration "couldn't disagree more with this ruling." He said the program carefully targets communications of suspected terrorists and "has helped stop terrorist attacks and saved American lives."
Taylor ordered an immediate halt to the program, but the government said it would ask for a stay of that order pending appeal. The American Civil Liberties Union, which brought the suit, said it would oppose a stay but agreed to delay enforcement of the injunction until Taylor hears arguments Sept. 7.
The ACLU filed the lawsuit in January on behalf of journalists, scholars and lawyers who say the program has made it difficult for them to do their jobs. They believe many of their overseas contacts are likely targets of the program, which monitors international phone calls and e-mails to or from the U.S. involving people the government suspects have terrorist links.
The ACLU says the 1978 Foreign Intelligence Surveillance Act, which set up a secret court to grant warrants for such surveillance, gave the government enough tools to monitor suspected terrorists.
The government argued that the NSA program is well within the president's authority but said proving that would require revealing state secrets.
The ACLU said the state-secrets argument was irrelevant because the Bush administration already had publicly revealed enough information about the program for Taylor to rule. The administration has decried leaks that led to a New York Times report about the existence of the program last year.
Taylor, a Carter appointee, said the government appeared to argue that the program is beyond judicial scrutiny.
"It was never the intent of the framers to give the president such unfettered control, particularly where his actions blatantly disregard the parameters clearly enumerated in the Bill of Rights," she wrote. "The three separate branches of government were developed as a check and balance for one another."
Administration officials said the program is essential to national security. The Justice Department said it "is lawful and protects civil liberties."
Homeland Security Secretary Michael Chertoff said eliminating it would put the nation in a "very, very weakened position."
"Without programs that allow us to do surveillance of communications and transactions in real time ... it will be as if in the Cold War we had dropped all the radar," he said in Los Angeles.
In Washington, Republicans expressed hope that the decision would be overturned, while many Democrats praised the ruling.
"It is disappointing that a judge would take it upon herself to disarm America during a time of war," Rep. Pete Hoekstra, R-Mich., chairman of the House Intelligence Committee, said in a statement.
ACLU executive director Anthony Romero called Taylor's opinion "another nail in the coffin in the Bush administration's legal strategy in the war on terror."
Taylor's ruling: http://www.mied.uscourts.gov/eGov/taylorpdf/06%2010204.pdf
Information on the case from the ACLU: http://www.aclu.org/nsaspying