A federal judge has ruled that the FBI’s practice of issuing so-called national security letters to banks, phone companies and other businesses is unconstitutional, saying the secretive demands for customer data violate the First Amendment.

The FBI almost always bars recipients of the letters from disclosing to anyone — including customers — that they have even received the demands, U.S. District Judge Susan Illston said in the ruling released Friday.

The government has failed to show that the letters and the blanket non-disclosure policy “serve the compelling need of national security,” and the gag order creates “too large a danger that speech is being unnecessarily restricted,” the San Francisco-based Illston wrote.

FBI counter-terrorism agents began issuing the letters, which don’t require a judge’s approval, after Congress passed the USA Patriot Act in the wake of the Sept. 11, 2001, attacks.

The case arises from a lawsuit that lawyers with the Electronic Frontier Foundation filed in 2011 on behalf of an unnamed telecommunications company that received an FBI demand for customer information.

“We are very pleased that the court recognized the fatal constitutional shortcomings of the NSL statute,” EFF lawyer Matt Zimmerman said. “The government’s gags have truncated the public debate on these controversial surveillance tools. Our client looks forward to the day when it can publicly discuss its experience.”

Illston wrote that she was also troubled by the limited powers judges have to lift the gag orders.

Judges can eliminate the gag order only if they have “no reason to believe that disclosure may endanger the national security of the United States, interfere with a criminal counter-terrorism, or counterintelligence investigation, interfere with diplomatic relations, or endanger the life or physical safety of any person.”

That provision also violated the Constitution because it blocks meaningful judicial review.

Illston ordered the FBI to cease issuing the letters, but put her order on hold for 90 days so the U.S. Department of Justice can appeal to the 9th U.S. Circuit Court of Appeals.

Illston isn’t the first federal judge to find the letters troubling. The 2nd U.S. Circuit Court of Appeals in New York also found the gag order unconstitutional, but allowed the FBI to continue issuing them if it made changes to its system such as notifying recipients they can ask federal judges to review the letters.

Illston ruled Friday that it’s up to Congress, and not the courts, to tinker with the letters.

In 2007, the Justice Department’s inspector general found widespread violations in the FBI’s use of the letters, including demands without proper authorization and information obtained in non-emergency circumstances. The FBI has tightened oversight of the system.

The FBI made 16,511 national security letter requests for information regarding 7,201 people in 2011, the latest data available. The FBI uses the letters to collect unlimited kinds of sensitive, private information like financial and phone records.

The DOJ didn’t immediately respond to a request for comment.