The National Security Agency spied on electronic communications between Americans in a program that was later scrapped after a judge ruled it illegal in 2011, US officials said on Thursday.

A senior official who spoke on condition of anonymity told reporters that the surveillance collection was "a result of a technological problem ...rather than any overreach by the NSA." Officials said the government had decided to declassify rulings from the Foreign Intelligence Surveillance Court, which reviews the legality of eavesdropping programs.

The court's opinions are usually top secret but the move to release the documents came amid a firestorm over revelations of sweeping surveillance operations, following bombshell disclosures from a former US intelligence contractor, Edward Snowden.

Officials said the court rulings had been declassified to better inform the public about how the eavesdropping programs are carried out, and that a mistake had occurred due to a technical problem and not an intentional invasion of privacy. The documents released show "the strong nature of the oversight of this program," the senior official said.

Under the program addressed by the court, the NSA had diverted a massive trove of international data flowing through fiber-optic cables in the United States, purportedly to sift through foreign communications. But the NSA proved unable to separate out emails between Americans, and the agency may have been collecting as many as 56,000 domestic communications every year, according to the Washington Post.