The Justice Department announced robbery and firearms charges Wednesday against a 20-year-old Bosnian man accused of stabbing, slashing and shooting NYPD officers in Brooklyn in early June.

Dzenan Camovic, who investigators said was in the country illegally, allegedly yelled “Allahu Akbar” while stabbing two officers, taking one of their guns and using it to shoot at additional police responding to the attack.

Attorney General William Barr said that investigators found some evidence of Camovic’s alleged support for the Islamic State group, but that he had covered his tracks with encrypted communications.

NYPD RELEASES KNIFE-ATTACK VIDEO: 'IT WAS A PLANNED ASSASSINATION ATTEMPT'

“Despite engaging in technical tradecraft that covered some of his tracks, this defendant cannot escape the reach of the investigators and prosecutors who are committed to making sure that he faces justice for his extremely serious crimes,” acting U.S. Attorney Seth DuCharme said.

New York City police officers work a scene early June 4, in the Brooklyn borough of New York.(AP Photo/Frank Franklin II)

The indictment alleges that Camovic, using protests in the city as cover, ambushed two NYPD members around 11:30 p.m. June 3. Surveillance video shows a man pass the two uniformed officers on the street, then creep around the block and get behind them.

“As fellow Americans were exercising their rights to demonstrate, these brave law enforcement officers were brutally attacked to further a violent agenda associated with ISIS and al-Qaeda,” said FBI Director Christopher Wray.

2 NYPD COPS SHOT, ANOTHER STABBED DURING 'UNPROVOKED' ATTACK

When Camovic reached them, investigators said he stabbed one officer in the neck and chased the other down, slashing him multiple times. Then he returned to the first victim, renewed his attack and stole the officer’s handgun, according to the indictment.

He opened fire on responding police, injuring “several” of them, and also shot one of the initial stabbing victims, according to prosecutors.

Police returned fire and wounded Camovic in the shootout before taking him into custody, authorities said.

“If not for the heroism and bravery of the responding NYPD officers who returned fire and took the assailant down early in the attack, untold additional officers and innocents could have been killed or injured,” Barr said.

CLICK HERE TO GET THE FOX NEWS APP

Camovic faces a maximum penalty of life in prison on robbery and felony federal firearms charges. He is currently in custody.