PORTLAND, Ore. — Hundreds gathered in downtown Portland outside the federal courthouse on Wednesday night, including mothers lined up in yellow shirts, fathers sporting leaf blowers and scores of young adults dressed in all black. The protest remained peaceful for hours, but devolved into violence in the early morning after demonstrators threw fireworks, water bottles and eggs at police, and officers answered with clubs, smoke bombs and tear gas.

The Portland Police Bureau is barred by a temporary restraining order from using tear gas on protesters unless officers believe lives are at risk. But around midnight, police said several officers had been injured and the fireworks being thrown by protesters put others in serious enough danger to declare a riot.

“Throwing incendiary devices towards people creates an extreme life safety issue,” the Portland Police Bureau said in a statement early Thursday morning.

The clash marks an escalation in police tactics after a week without using tear gas to quell demonstrations that have at times grown destructive. The Portland police have been the target of intense scrutiny for their response to protests since May 29. Critics have alleged officers have been quick to indiscriminately gas largely peaceful crowds, when only a small number of individuals commit crimes such as throwing projectiles at officers and setting fires.

That perception was exacerbated last month when the Trump administration sent federal police into the city, ostensibly to quell unrest and protect the federal courthouse from property damage. The federal officers repeatedly used large amounts of tear gas on crowds that numbered in the thousands.

Thursday’s event began with a relatively calm crowd gathered in the park near the federal courthouse and a downtown police precinct. One protester spoke to the crowd over a loudspeaker, urging them to remain peaceful throughout the night.

“We need to hold each other accountable,” Edreece Phillips said over a bullhorn. “We are not about destruction. We’re about to rebuild a people.”

For almost three hours, the crowd remained largely peaceful. A reinforced metal fence kept the crowd at the edge of the sidewalk outside of the Mark O. Hatfield federal courthouse, and demonstrators mostly ignored the neighboring Justice Center. Music blasted over loudspeakers and the atmosphere was more charged than the previous night, when a much smaller protest ended peacefully.

A little after 11 p.m., a handful of people in the crowd began throwing projectiles at the federal courthouse. They tossed glass bottles and flaming projectiles that sailed over the fence and smoldered on the sidewalk. Someone in the crowd tossed a firework that exploded in bright green sparks.

Shortly after that, Portland police began to emerge from their precinct in the building across the street. A small group of officers tried to come out of a back entrance, but protesters overwhelmed them and they retreated inside again. Some in the crowd threw raw chicken breasts at the precinct’s door.

Eventually, dozens of riot police rolled up in vans and declared an unlawful assembly.

Police repeatedly rushed the crowd, stopping to reform their line at intersections. Protesters fled, then turned around and confronted officers again each time they stopped.

Several people threw water bottles and eggs at the police. At least two officers were struck with a paint-filled balloon.

Police slashed the tires on a Portland Timbers Army van, which belongs to the local soccer fan club and had been marked with red crosses indicating it was stocked with medical supplies. Officers attempted to make a few arrests after they spotted people throwing projectiles, but in at least one case, a protester ran back into the crowd before police could grab him.

People threw multiple fireworks at the police throughout the night, but often the sparks fell short and exploded closer to the front line of the protest. When one landed at the feet of police, an officer kicked the lit firework back toward the crowd and it ignited in the space between them.

The Portland Police Bureau said one officer’s hand was “severely hurt” and several others sustained minor injuries during the event. Officers made several arrests, including one individual who allegedly vandalized a police cruiser parked on the street, but further details were not immediately released by police.

Police declared a riot at 11:59 p.m., and a short time later they began using tear gas to disperse the crowd. Some protesters stood or sat in the street with respirators on and refused to move as the fumes rose in plumes around them, but most scattered.

Police pursued the protesters, forcing them to split up and regroup several times. Eventually, after police deployed gas several times, people left and the gathering petered out by 2:30 a.m.