This is an archived article and the information in the article may be outdated. Please look at the time stamp on the story to see when it was last updated.

FLATBUSH, Brooklyn — Two police officers were shot after another officer was stabbed in an unprovoked ambush in Brooklyn late Wednesday night, the NYPD said.

According to Police Commissioner Dermot Shea, two officers were working an anti-looting post at the corner of Church and Flatbush avenues around 11:45 p.m. when a man armed with a knife walked up casually and stabbed one of the cops in the side of the neck.

A struggle ensued and police believe the suspect managed to grab a gun from one of the officers before shots were fired.

According to authorities, two other NYPD officers in the area heard the shots and rushed to the scene. More shots were fired, police said.

When all was said and done, two cops had suffered gunshot wounds to the hand and the suspect was shot multiple times, Shea said.

All three officers were rushed to a nearby hospital. Officer Yayonfrant Jean Pierre is expected to recover from stab wounds in the neck. The other wounded officers, Randy Ramnarine and Dexter Chiu, also are expected to recover.

“Thank God we’re not planning a funeral right now,” Shea said at an early Thursday press conference overnight.

PIX11’s Anthony DiLorenzo obtained footage from nearby in which you can hear the moment gunfire erupted between police and the suspect, 22 shots fired in total.

Mayor Bill de Blasio rushed to the Brooklyn hospital after hearing of the shooting, a spokeswoman said.

According to police, the suspect remained hospitalized in critical condition Thursday morning.

The FBI’s Joint Terrorism Task Force was spotted on the scene Thursday morning and has joined the investigation.

In a statement, FBI New York ADIC William Sweeney Jr. called the attack “cowardly” and said FBI New York is “fully engaged” in the investigation. “We respond as if one of our own was attacked, and we will use every federal statute available to hold the perpetrator accountable.”

Commissioner Shea hinted at the possibility of federal charges being filed against the suspect, which is not always standard in clashes between police and suspects.

Multiple law enforcement sources tell PIX11 News the suspect is Dzenan Camovic, 20, of Brooklyn and that the FBI is looking into possible his ties to terrorist affiliations.

There is no word yet on official charges the alleged attacker will face if he survives.

Shea said it was too “soon to make statements at this point” about any impetus for the stabbing.

There was also a police-involved shooting in Crown Heights on Tuesday night. An armed gunman was fatally shot in that incident.