WASHINGTON -- The Obama administration has given up more of its surveillance secrets, acknowledging that it was ordered to stop scooping up thousands of Internet communications from Americans with no connection to terrorism — a practice it says was an unintended consequence when it gathered bundles of Internet traffic connected to terror suspects.

One of the documents that intelligence officials released Wednesday came because a court ordered the National Security Agency to do so. But it's also part of the administration's response to the leaks by analyst-turned-fugitive Edward Snowden, who revealed that the NSA's spying programs went further and gathered millions more communications than most Americans realized.

The NSA declassified three secret court opinions showing how it revealed to the Foreign Intelligence Surveillance Court that one of its surveillance programs may have collected and stored as many as 56,000 emails and other communications by ordinary Americans annually over three years. The court ruled the NSA actions unconstitutional and ordered the agency to fix the problem, which it did by creating new technology to filter out buckets of data most likely to contain U.S. emails, and then limit the access to that data.

The director of national intelligence, James Clapper, released the information Wednesday "in the interest of increased transparency," and as directed by President Barack Obama in June, according to a statement accompanying the online documents.

But it wasn't until the Electronic Freedom Foundation, an Internet civil liberties group that sued for the release of one of the documents, disclosed the court order that Obama administration officials also acknowledged that the release was prodded by the group's 2012 lawsuit.

The court opinions show that when the NSA reported its inadvertent gathering of American-based Internet traffic in September 2011, the Foreign Intelligence Surveillance Court ordered the agency to find ways to limit what it collects and how long it keeps the material.

In an 85-page declassified FISA court ruling from October 2011, U.S. District Judge James D. Bates rebuked government lawyers for repeatedly misrepresenting the operations of the NSA's surveillance programs.

Bates wrote that the NSA had advised the court that "the volume and nature of the information it had been collecting is fundamentally different than what the court had been led to believe," and went on to say the court must consider "whether targeting and minimization procedures comport with the Fourth Amendment" prohibition against unreasonable search and seizure.

"This court is troubled that the government's revelations regarding NSA's acquisition of Internet transactions mark the third instance in less than three years in which the government has disclosed a substantial misrepresentation regarding the scope of a major collection program," Bates added in a footnoted passage that had portions heavily blacked out.

Bates also complained that the government's submissions make clear that the NSA was gathering Internet data years before it was authorized by the USA Patriot Act's Section 702 in 2008.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

The NSA had moved to revise its Internet surveillance in an effort to separate out domestic data from its foreign targeted metadata — which includes email addresses and subject lines. But in his October 2011 ruling, Bates said the government's "upstream" collection of data — taken from internal U.S. data sources — was unconstitutional.

Three senior U.S. intelligence officials said Wednesday that national security officials realized the extent of the NSA's inadvertent collection of Americans' data from fiber optic cables in September 2011. One of the officials said the problem became apparent during internal discussions between the NSA and Justice Department officials about the program's technical operation.

The problem, according to the officials, was that the top secret Internet-sweeping operation, which was targeting metadata contained in the emails of foreign users, was also amassing thousands of emails that were bundled up with the targeted materials. Because many Web mail services use such bundled transmissions, the official said, it was impossible to collect the targeted materials without also sweeping up data from innocent domestic U.S. users.

Officials said that when they realized they had an American communication, the communication was destroyed. But it was not clear how they determined to whom an email belonged and whether any NSA analyst had actually read the content of the email. The officials said the bulk of the information was never accessed or analyzed.

As soon as the extent of the problem became clear, the officials said, the Obama administration provided classified briefings to both Senate and House intelligence committees within days. At the same time, officials also informed the FISA court, which later issued the three 2011 rulings released Wednesday — with sections blacked out — as part of the government's latest disclosure of documents.

The officials briefed reporters on condition of anonymity because they were not authorized to do so by name.

The documents were declassified to help the Obama administration explain some of the most recent disclosures made by The Washington Post after it published classified documents provided by Snowden, the former NSA systems analyst.

But the FISA court's classified rulings have also been at issue in a year-old lawsuit filed against the government by the Electronic Frontier Foundation.

The release Wednesday of the FISA opinion, two other 2011 rulings and a secret "white paper" on the NSA's surveillance came less than two weeks after a federal judge in Washington gave government lawyers a time extension in order to decide which materials to declassify. The EFF had been pressing for a summary judgment that would have compelled the government to release the secret FISA rulings, and the government's most recent extension expired Wednesday, the day it released the once-secret FISA court rulings.

"This was all released in response to the court's orders," said Mark Rumold, an EFF attorney involved in the litigation.

A senior administration official acknowledged Wednesday that some of the documents released were in response to the lawsuit, while others were released voluntarily. The official insisted on anonymity because he was not authorized to discuss the release with a reporter by name.

The documents were posted later in the day on a new website that went live Wednesday afternoon. The front page of the site said it was "created at the direction of the president of the United States (and) provides immediate, ongoing and direct access to factual information related to the lawful foreign surveillance activities carried out by the U.S. intelligence community."

These interceptions of innocent Americans' communications were happening when the NSA accessed Internet information "upstream," meaning off fiber optic cables or other channels where Internet traffic traverses the U.S. telecommunications system.

The NSA disclosed that it gathers some 250 million Internet communications each year, with some 9 percent from these "upstream" channels, amounting to 20 million to 25 million emails a year. The agency used statistical analysis to estimate that of those, possibly as many as 56,000 Internet communications collected were sent by Americans or people in the U.S. with no connection to terrorism.

Under court order, the NSA resolved the problem by creating new ways to detect when emails by people within the U.S. were being intercepted and separated those batches of communications. It also developed new ways to limit how that data could be accessed or used. The agency also agreed to only keep these bundled communications for possible later analysis for a two-year period, instead of the usual five-year retention period.

The agency also, under court order, destroyed all the bundled data gathered between 2008, when the FISA court first authorized the collection under Section 702 of the Patriot Act, and 2011, when the new procedures were put in place.

The court signed off on the new procedures.

White House spokesman Josh Earnest said the program is specifically to gather foreign intelligence, not spy on Americans.

"The reason that we're talking about it right now is because there are very strict compliance standards in place at the NSA that monitor for compliance issues, that tabulate them, that document them and that put in place measures to correct them when they occur," Earnest said.

Related: