WASHINGTON—The National Security Agency's searches of a database containing the phone records of nearly all Americans violated privacy protections for three years by failing to meet a court-ordered standard, according to court documents released Tuesday.

The documents showed the violations continued until a judge ordered an overhaul of the program in 2009.

Since the breadth of the phone-records collection came to light through leaks by former NSA contractor Edward Snowden, U.S. officials have said that for all queries of the database, the NSA must show a "reasonable articulable suspicion" that the phone number being targeted is associated with a terrorist organization.

Between 2006 and 2009, however, of the 17,835 phone numbers checked against phone records, only 1,935 were based on that reasonable-suspicion standard, intelligence officials said.

In a March 2009 order that was declassified Tuesday, Judge Reggie Walton of the Foreign Intelligence Surveillance Court said the government had so "frequently and systematically violated" the procedures it had said it was following that a critical element of the program "never functioned effectively." The judge criticized what he described as "repeated inaccurate statements made in the government's submissions."