A US federal judge sharply rebuked the National Security Agency in 2011 for repeatedly misleading the court that oversees its surveillance on domestic soil, including a programme that is collecting tens of thousands of domestic e-mails and other internet communications of Americans each year, according to a secret ruling that has now been made public.
The 85-page ruling by Judge John Bates, then serving as chief judge on the Foreign Intelligence Surveillance Court, involved an NSA programme that searches the contents of Americans' international internet communications without a warrant in a hunt for discussions about foreigners who have been targeted for surveillance.
The Justice Department had told Bates that NSA officials had discovered that the programme had also been gathering domestic messages for three years.
Bates found that the agency had violated the Constitution and declared the problems part of a pattern of misrepresentation by agency officials in submissions to the secret court.
The release of the ruling on Wednesday was the latest effort by the Obama administration to contain revelations about NSA surveillance prompted by leaks by the former agency contractor Edward Snowden.
The e-mails the agency intercepted from Americans represented a relatively small percentage of the estimated 250 million communications it intercepts each year, according to the ruling. And while the documents show the NSA fixed the problems to the court's satisfaction, they also revealed further issues.
In particular, Bates portrayed the domestic surveillance as only the latest time the agency had misled the oversight court.
"The 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 programme," he wrote.
One of the examples, he wrote, was redacted in the ruling. Another involved a separate NSA programme that keeps logs of all domestic phone calls, which the court approved in 2006 and which came to light in June as a result of leaks by Snowden.
The Electronic Frontier Foundation, a free speech and privacy rights group, sued to obtain the ruling after Democratic Senator Ron Wyden of Oregon - who sits on the Senate Intelligence Committee - fought last summer to declassify information related to a surveillance court ruling that the NSA had violated the Fourth Amendment.
Wyden - an outspoken critic of NSA surveillance - said declassification of the ruling was "long overdue".
He argued that while the NSA had increased privacy protections for purely domestic and unrelated communications that were swept up in the surveillance, the collection itself "was a serious violation of the Fourth Amendment".
Mark Rumold, of the Electronic Frontier Foundation, praised the administration for releasing the document with relatively few redactions, although he criticised the time and the difficulty in obtaining it. But he also said that the ruling showed that the surveillance court was not equipped to perform adequate oversight of the NSA.
"This opinion illustrates that the way the court is structured now it cannot serve as an effective check on the NSA because it's wholly dependent on the representations that the NSA makes to it," Rumold said.
"It has no ability to investigate. And it's clear that the NSA representations have not been entirely candid to the court."
A senior intelligence official said the ruling showed that NSA oversight was robust and serious.