The National Security Agency headquarters in Fort Meade. (NATIONAL SECURITY AGENCY)

A federal judge Friday upheld the U.S. government’s decision to keep secret a pre-2012 legal opinion by the nation’s foreign intelligence surveillance court that barred authorities from analyzing certain data collected from the pipelines of the Internet.

The 12-page decision by U.S. District Judge Rosemary M. Collyer of the District of Columbia came in a Freedom of Information Act lawsuit filed in May 2014 by the Electronic Frontier Foundation (EFF), a nonprofit civil liberties group.

The opinion, which Collyer called the Section 1809 Opinion, held that federal law barred the surveillance court from approving the government’s proposed use of data obtained without authorization through “upstream” collection — the gathering of communications from the “internet backbone,” or the main cables and switches of U.S. Internet service providers.

The opinion’s existence is known because the surveillance court referred to it in redacted form in an Oct. 3, 2011, opinion released in August 2013 in another FOIA suit by the EFF.

Collyer said the opinion is exempt from FOIA because it contains classified information concerning intelligence methods and the National Security Agency’s collection of electronic information.

“The Court finds that disclosure of any part of the . . . Opinion could reasonably be expected to cause grave damage to national security,” Collyer wrote.