D.C. police were overwhelmed by violent demonstrators on the day President Trump was inaugurated, and some officers indiscriminately fired pepper spray and other nonlethal munitions and arrested people not involved in destructive behavior, according to an independent group that advises law enforcement.

The nonprofit Police Foundation said in a report issued Tuesday that overworked officers felt staffing was insufficient and orders were inconsistent. One officer testified in court, and was quoted in the report, as saying that he “personally did not feel prepared for the situation that was in front of us.”

The report praises officers who it said handled at least 20 separate protest groups on Jan. 20, 2017 — some marching peacefully, others blocking entrances to the route of the inaugural parade — with professionalism. An independent legal observer told the foundation that most officers “were peaceful and professional throughout the day.”

But the report says officers strained or broke regulations while confronting one core group of demonstrators, many of whom were dressed in full black and were part of a group called DisruptJ20. Some among the group assaulted officers and damaged buildings and vehicles in a 16-block area around Franklin Square, and then quickly disappeared into larger crowds.

Unable to isolate those who were breaking windows and throwing projectiles at officers, the report says, police leaders “determined that based on the totality of the circumstances a crime had been committed and the whole group would be arrested.”

A total of 234 people were detained for hours before being charged with rioting.

Twenty-one of the people arrested pleaded guilty. Prosecutors at two trials were unable to obtain convictions because they could not conclusively match suspects to specific acts of violence.

Most of the rioting cases were dropped. The U.S. Attorney’s Office for the District of Columbia on Friday moved to dismiss charges against the final 39 defendants in the case who were awaiting trial, ending the prosecutions.

The policing report concludes that when the demonstration turned violent, some officers abandoned training and rules for handling protests and that their failure to prevent rioting “contributed to a large number of First Amendment demonstrators arrested who were not directly involved in destructive or violent behavior.”

The Police Foundation did not return calls to its office.

D.C. police did not respond to requests to comment on the report. D.C. Police Chief Peter Newsham previously has defended the department’s tactics and has said the police response changed when the rioting started, shifting away from rules dealing with First Amendment-protected demonstrations to those dealing with criminal conduct. After prosecutors threw out the remaining criminal cases on Friday, Newsham said that “sometimes the bad guys win,” while promising to “adjust our tactics” to deal with future disturbances.

In an interview with The Washington Post Magazine published in June, Newsham called the Inauguration Day protests “unique.”

“These are people that were involved in a riot. And whenever you have a riot you see fires burning, you see windows being smashed, you see rocks, boulders and pieces of steel being thrown at human beings. People expect the police to come in and restore order. And I think we did a really good job of that,” Newsham said in that interview.

An internal report containing the department’s view of how officers handled the riot has not yet been made public.

In addition, a lawsuit filed by several demonstrators and the American Civil Liberties Union alleging mistreatment and unlawful arrest is pending in federal court.

Scott Michelman, a senior attorney for the ACLU of the District and the lead litigator in the Inauguration Day lawsuit, said the Police Foundation report backs many of his clients’ claims. “You had police round up a group of people without probable cause to believe that each of them had violated the law,” he said. “It was guilty-by-association policing.”

The Police Foundation undertook its study after being contracted by the D.C. Office of Police Complaints, an independent District government agency monitoring police policy and conduct. The complaints office concluded in its own report in February that officers were overzealous in their use of pepper spray and other crowd-control tools. The office then asked the foundation to take a more-comprehensive look.

The foundation said it relied on media accounts, videos and pictures, including video from 550 police body-worn cameras, and testimony of officers in court. Officers and other police officials, including Newsham, did not speak to investigators, citing pending civil litigation.

City officials say seven officers were injured when protesters threw rocks, bottles, bricks and metal poles, and that $100,000 in damage was caused to storefronts and vehicles as the march progressed from Logan Circle through Franklin Square.

The report says the group’s tactics confused and overwhelmed officers. A police commander declared a riot in progress as the group approached L Street from 12th and 13th streets. That commander authorized officers to fire pepper spray that shoots several feet from large canisters, and to throw “sting balls.”

But the report concluded that “less than lethal weapons were used indiscriminately and without adequate warnings in certain circumstances.” The foundation quoted officers who testified in court during the failed prosecutions. One said “it would have been a safety concern for him to attempt to arrest the individuals committing these acts.” Another said “there were too few officers to effectively prevent or quickly respond to individuals who engaged in property damage or other illegal activities.”

The foundation said that some officers appeared to target peaceful demonstrators with pepper spray, or to spray groups of people “that posed no immediate threat.”