WASHINGTON — A federal judge ruled on Wednesday that a federal government database that compiles people deemed to be “known or suspected terrorists” violates the rights of American citizens who are on the watchlist, calling into question the constitutionality of a major tool the F.B.I. and the Department of Homeland Security use for screening potential terrorism suspects.

Being on the watchlist can restrict people from traveling or entering the country, subject them to greater scrutiny at airports and by the police, and deny them government benefits and contracts. In a 32-page opinion, Judge Anthony J. Trenga of United States District Court for the Eastern District of Virginia said the standard for inclusion in the database was too vague.

“The court concludes that the risk of erroneous deprivation of plaintiffs’ travel-related and reputational liberty interests is high, and the currently existing procedural safeguards are not sufficient to address that risk,” Judge Trenga wrote.

[Read the ruling.]

As of 2017, about 1.2 million people were on the watchlist, which is maintained by the F.B.I.’s Terrorist Screening Center. Although a vast majority of them were foreigners abroad, about 4,600 were American citizens who are protected by the Constitution.

Among them, a group of 19 Americans, represented by the Council on American-Islamic Relations, filed a lawsuit charging that their inclusion violated their due process rights. Recounting tales of being detained and harassed when trying to enter the country, they argued that they did not receive notice of why they were being put on the list or an opportunity to contest derogatory claims.

The judge agreed that the current procedures were inadequate to protect their rights, granting the plaintiffs summary judgment. But he stopped short of saying what should happen next, asking the Justice Department and the lawyers for the plaintiffs to submit briefings on the difficult question of “what kind of remedy can be fashioned to adequately protect a citizen’s constitutional rights while not unduly compromising public safety or national security.”

The Council on American-Islamic Relations hailed the ruling as a “complete victory.” In a statement, Nihad Awad, its executive director, said the group’s “legal team has finally brought an end to the secretive watchlist, which is effectively a Muslim registry created in the wake of the widespread Islamophobia of the early 2000s.”

Joshua Stueve, a spokesman for the United States attorney for the Eastern District of Virginia, declined to comment. But in court, government lawyers had argued that the case should instead be dismissed. Among other things, Justice Department lawyers asserted that the plaintiffs lacked standing to bring the case, and they urged Judge Trenga to defer to the executive branch’s decisions because combating terrorism was a national security matter.

The government’s use of terrorism watchlists has grown enormously since the Sept. 11, 2001, attacks, and over time, the practice — and the opaque standards and rationales by which people’s names are added to such databases — has come under harsh scrutiny by civil libertarians.

The present case involves a broad watchlist, called the Terrorist Screening Database. It is maintained by the F.B.I., but other agencies can nominate people for inclusion on the list based on intelligence that may never be shared with them.

A subset of the people on the watchlist are also put on the more restrictive No Fly List, which bars them from boarding planes in the United States or flying through American airspace. In 2014, a federal judge in Oregonruled that the government’s use of the No Fly List to bar Americans from boarding planes was unconstitutional, requiring the Department of Homeland Security to overhaul its Traveler Redress Inquiry Program procedures.

Later that same year, Judge Trenga struck down a use of the No Fly List to keep a particular American, Gulet Mohamed, from boarding a flight home, effectively exiling him. The judge’s ruling about the broader watchlist on Wednesday built on his earlier opinion, which he quoted from extensively.

Judge Trenga noted that most of the plaintiffs in the current case did not claim to be on the more restrictive No Fly List, but said their inclusion on the broader Terrorist Screening Database — which he referred to by the initials TSDB — raised similar issues because of the burden of going through the delays and humiliations of enhanced screenings that led some plaintiffs to avoid traveling.

“While inclusion in the TSDB does not constitute a total ban on international travel in the same way that inclusion on the No Fly List does,” he wrote, “the wide-ranging consequences of an individual’s watchlist status render it more closely analogous to the No Fly List than to the types of regulations that courts have found to be reasonable regulations that still facilitated access and use of means of travel.”

He also noted that the terrorism watchlist was used for screening government contractors and was shared with state and local law enforcement agencies, which increases their risk of “being surrounded by police, handcuffed in front of their families and detained for many hours.”

Files released by the F.B.I. in 2011 under the Freedom of Information Act showed that the F.B.I. was permitted to include people on the watchlist even if they had been acquitted of terrorism-related offenses or the charges are dropped.

Judge Trenga was appointed in 2008 by President George W. Bush.

New York Times