A federal judge who oversaw a secret spy court almost shut down the U.S. government's domestic surveillance program designed to fight terrorism after he "lost confidence" in officials' ability to operate it, documents released Tuesday show.

U.S. District Judge Reggie Walton issued a blistering opinion in March 2009 after discovering government officials had been accessing domestic phone records for nearly three years without "reasonable, articulate suspicion" that they were connected to terrorism.

Walton said the government's excuse that the program was complicated "strained credulity," and he ordered the National Security Agency to conduct an "end-to-end" review of its processes and policies while also ordering closer monitoring of its activities.

Later in 2009, a Justice Department lawyer reported to the spy court a "likely violation" of NSA surveillance rules. The lawyer said that in some cases, it appeared the NSA was distributing the sensitive phone records by email to as many as 189 analysts, but only 53 were approved by the Foreign Intelligence Surveillance Court to see them.

Judge Walton wrote that he was "deeply troubled by the incidents," which he said occurred just weeks after the NSA had performed a major review of its internal practices because of the initial problems reported earlier in the year.

Walton's dissatisfaction with the Obama administration's handling of the surveillance program are contained in hundreds of pages of previously classified documents federal officials released Tuesday as part of a lawsuit by a civil liberties group.

The Obama administration has been facing mounting pressure to reveal more details about the government's domestic surveillance program since a former intelligence contractor released documents showing massive National Security Agency trawling of domestic data.

The information included domestic telephone numbers, calling patterns and the agency's collection of Americans' Internet user names, IP addresses and other metadata swept up in surveillance of foreign terror suspects.

The documents released Tuesday came in response to a lawsuit filed by the Electronic Frontier Foundation. They relate to a time in 2009 when U.S. spies went too far in collecting domestic phone data and then misled the secret Foreign Intelligence Surveillance Court about their activities.

The Obama administration's decision to release the documents comes just two weeks after it declassified three secret FISC opinions — including one in response to a separate EFF lawsuit in the federal court in Washington. In that October 2011 FISA opinion, Judge James D. Bates said he was troubled by at least three incidents over three years where government officials admitted to mistaken collection of domestic data.