“Contrary to the government’s repeated assurances, N.S.A. had been routinely running queries of the metadata using querying terms that did not meet the standard for querying,” Judge Bates recounted. He cited a 2009 ruling that concluded that the requirement had been “so frequently and systematically violated that it can fairly be said that this critical element of the overall ... regime has never functioned effectively.”

The Electronic Frontier Foundation, a free speech and privacy rights group, sued to obtain the ruling after Senator Ron Wyden, an Oregon Democrat who sits on the Senate Intelligence Committee, fought last summer to declassify the basic fact that the surveillance court had ruled that the N.S.A. had violated the Fourth Amendment.

In a statement, Mr. Wyden — an outspoken critic of N.S.A. surveillance — said declassification of the ruling was “long overdue.” He argued that while the N.S.A. 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 criticized the time and the difficulty in obtaining it. But he also said the ruling showed the surveillance court was not equipped to perform adequate oversight of the N.S.A.

“This opinion illustrates that the way the court is structured now it cannot serve as an effective check on the N.S.A. because it’s wholly dependent on the representations that the N.S.A. makes to it,” Mr. Rumold said. “It has no ability to investigate. And it’s clear that the N.S.A. representations have not been entirely candid to the court.”

A senior intelligence official, speaking to reporters in a conference call, portrayed the ruling as showing that N.S.A. oversight was robust and serious. He said that some 300 N.S.A. employees were assigned to seek out even inadvertent violations of the rules and that the court conducted “vigorous” oversight.

The ruling focused on a program under which the N.S.A. has been searching domestic Internet links for communications — where at least one side is overseas — in which there are “strong selectors” indicating insider knowledge of someone who has been targeted for foreign-intelligence collection. One example would be mentioning a person’s private e-mail address in the body of an e-mail.