Police in riot gear contain a group of protesters at the corner of 12th and L streets NW on the day of President Trump’s inauguration. (Jahi Chikwendiu/The Washington Post)

Federal prosecutors must scale back their search of Facebook accounts connected to protests during President Trump’s inauguration to protect private data unrelated to the ongoing probe, a judge in Washington has ruled.

“The risk for disclosure of private political speech and association of innocent persons to the government cannot be ignored and therefore additional protections are necessary,” D.C. Superior Court Chief Judge Robert E. Morin ruled.

The ruling is the latest development in a legal battle over the government’s request to search three Facebook accounts, including that of a political group that helped plan the Jan. 20 demonstrations. More than 200 people were arrested and are facing felony rioting charges connected to the protests that injured police and damaged property in downtown Washington.

The judge ordered Facebook to redact the identities of about 6,000 people who liked or followed the DisruptJ20 Facebook page and to limit the production of photographs. However, Morin did not go as far as attorneys for the two individual users had requested to limit the search of their private content.

“The court agreed to impose safeguards to protect political activity and third-party communications from government snooping, but was not equally careful to protect our clients’ private and personal communications,” Scott Michelman, an attorney with the ACLU of the District of Columbia, said in a statement.

The fight over the warrants became public after Facebook went to the D.C. Court of Appeals to protest a judge's order that prevented the company from alerting its users to the search. Prosecutors in the District backed off their request to keep Facebook quiet in September, allowing the company to alert the three users.

In his 21-page order issued Thursday, Morin distinguished between the two individual accounts and the DisruptJ20 Facebook page used as a “common forum” by many people. The judge said he was trying to balance individual rights to private online expression with the government’s ability to prosecute criminals.

Among other limitations, Morin ordered investigators to clear their search plan with the court before accessing the DisruptJ20 page and get the court’s permission to uncover any third-party names.

“While the government has the right to execute its warrants, it does not have the right to rummage through the information contained on the Facebook accounts and discover the identity of, or access communications by, individuals not participating in alleged criminal activity, particularly those persons who were engage in protected First Amendment activities,” Morin wrote.

The individual targets of the search — Lacy MacAuley and Legba Carrefour — have not been charged with any crime. The judge ordered the names redacted of MacAuley's and Carrefour's Facebook friends and the names of anyone who communicated with the two.

But Morin ruled that because the government has “established probable cause to believe that criminal activity is likely to be found in the individual accounts,” investigators can review those communications and postings.

The office of the U.S. attorney for the District had no comment on the ruling.