A federal judge on Friday struck down gag orders imposed on companies that receive national security letters — the supersecret mechanism by which the FBI can get your private information without a warrant in the name of counterterrorism.

In a ruling filed Friday afternoon in San Francisco, U.S. District Judge Susan Illston declared the letters — which prohibit recipients from even acknowledging they have received them, much less discuss their circumstances — an unconstitutional violation of the First Amendment.

Illston ordered the FBI to stop issuing the letters, known as NSLs, and to stop enforcing the gag orders. She stayed enforcement of her ruling for 90 days to give the government time to appeal.

The Justice Department said it was studying the decision and had no immediate comment.

Read the full ruling (.pdf)

The letters have been the focus of intense controversy, with government officials calling them vital to fighting terrorism and civil liberties advocates calling them a gross infringement of Americans' rights.

While the letters have been part of federal law since the 1980s, their use grew rapidly after they were endorsed in the USA Patriot Act following the terrorist attacks of Sept. 11, 2001. FBI reports filed to Congress show the agency issued 16,511 NSLs in 2011, the latest year for which full data are available.

Watch US News videos on NBCNews.com

The letters are an administrative way under the Electronic Communications Privacy Act for the FBI to order companies that provide any sort of communications services — phone companies, Internet service providers, banks and the like — to hand over information about their customers without court approval.

They come with an indefinite secrecy order, preventing the companies from ever letting their customers know their information has been surrendered.

"We are very pleased that the court recognized the fatal constitutional shortcomings of the NSL statute," said Matt Zimmerman, a senior staff attorney for the Electronic Frontier Foundation, the civil liberties group that filed the case on behalf of a telecommunications client it can't name under the law.

"The government's gags have truncated the public debate on these controversial surveillance tools," Zimmerman said. "Our client looks forward to the day when it can publicly discuss its experience."

Illston concluded that the secrecy provision couldn't be separated from the main body of the law because Congress meant for the letters to remain secret. She concluded that the entire section of that law governing the letters was unconstitutional.

"The government has a strong argument that allowing the government to prohibit recipients of NSL's from disclosing the specific information sought in NSL's to either the targets or the public is generally necessary to serve national security in ongoing investigations," Illston wrote.

"However, the government has not shown that it is generally necessary to prohibit recipients from disclosing the mere fact of their receipt of NSLs."

Follow M. Alex Johnson on Twitter and Facebook.

Related:

Petraeus case shows ease of government email snooping