NEW YORK -- Police were trying Thursday to determine what motivated a stabbing ambush of an officer on an anti-looting patrol in Brooklyn, an attack that spurred a struggle in which the suspect was shot and two other officers had gunshot injuries to their hands.

Officer Yayonfrant Jean Pierre, who was stabbed in the neck, and the other wounded officers, Randy Ramnarine and Dexter Chiu, were expected to recover. The suspect, whose name has not been released, was hospitalized in critical condition after being shot multiple times, Police Commissioner Dermot Shea said.

The bloodshed happened just before midnight Wednesday, in the hours after an 8 p.m. curfew that was intended to quell days of unrest over George Floyd's death at the hands of a Minneapolis police officer.

Shea said Thursday it is "preliminary to be making statements at this point" about the impetus for the stabbing or any of several other attacks on city police in recent days. Mayor Bill de Blasio said he was "not going to theorize on" motives for such attacks.

"Anyone who attacks a police officer attacks all of us. Period," the Democratic mayor said at a news conference. "There will be consequences."

Police union head Patrick Lynch, however, said he saw a connection between Wednesday's stabbing and the protests over Floyd's death.

"Did we doubt? Because of the rhetoric we're hearing, the anti-police rhetoric that's storming our streets, are we surprised?" the Police Benevolent Association president said earlier Thursday. "I'm not. We said it's going to happen."

New York City has been roiled by days of mostly peaceful but sometimes violent protests over Floyd's death, and by smash-and-grab sprees amid the unrest. Wednesday's stabbing happened a block from a spot where demonstrators and police engaged days earlier in an hourslong standoff, during which a police car was burned and protesters were beaten with batons.

On Wednesday, Shea said the attacker casually approached two officers stationed in the area to prevent pilfering around 11:45 p.m. and stabbed one -- Jean Pierre, according to de Blasio.

Officers a short distance away heard gunshots, rushed to the scene and saw the man with a gun in his hand, believed to have been taken from one of the officers, Shea said. The responding officers then opened fire.

"It appears to be a completely, cowardly, despicable, unprovoked attack," Shea said.

The commissioner said 22 shell casings were recovered. He didn't say whether the officers' hand wounds came from fellow officers' guns.

Jean Pierre is a Haitian immigrant, and Ramnarine and Chiu are children of immigrants, de Blasio said.

They represent "all that is great about New York City," de Blasio said. "They represented the fact that people come from all over this country, all over this world, to find a better life ... and then some choose to serve all of us."

The stabbing was one of multiple assaults on police officers in recent days, including a driver plowing into a sergeant trying to stop stealing in the Bronx and a lieutenant who was struck in the helmet by a brick during a brawl with protesters in Manhattan.

Gov. Andrew Cuomo called the attacks "unconscionable."

"People attack police officers? They run up to police officers, they stab a police officer? They've treated police officers with such disrespect in New York City that I am stunned," Cuomo, a Democrat, said at a news briefing in Albany.

William F. Sweeney Jr., head of the FBI's New York office, condemned the "cowardly attack on the NYPD" in a statement posted to Twitter. Sweeney said the bureau would use "every federal statute available to hold the perpetrator accountable."

------

Associated Press writers Jennifer Peltz in New York and Marina Villaneuve in Albany contributed

Correction:

This story has been corrected to show that the stabbing happened at 11:45 p.m., not 11:45 a.m.