WASHINGTON – U.S. intelligence agencies conducted illegal surveillance on American citizens over a five-year period, a practice that earned them a sharp rebuke from a secret court that called the matter a "very serious" constitutional issue.

The criticism is in a lengthy secret ruling that lays bare some of the frictions between the Foreign Intelligence Surveillance Court and U.S. intelligence agencies obligated to obtain the court's approval for surveillance activities.

The ruling, dated April 26 and bearing the label "top secret," was obtained and published by the news site Circa.

The document said the court had learned in a notice filed Oct. 26, 2016, that National Security Agency analysts had been conducting prohibited queries of databases "with much greater frequency than had previously been disclosed to the court."

It said a judge chastised the NSA's inspector general and Office of Compliance for Operations for an "institutional 'lack of candor' " for failing to inform the court. It described the matter as "a very serious Fourth Amendment issue."

Parts of the ruling were redacted, including sections that give an indication of the extent of the illegal surveillance, which the NSA told the court in a Jan. 3 notice was partly the fault of "human error" and "system design issues" rather than intentional illegal searches.

The court document also criticized the FBI's distribution of intelligence data, saying it had disclosed raw surveillance data to sectors of its bureaucracy "largely staffed by private contractors."