According to court documents 'Numerous members of law enforcement witnessed the defendant's attack on an FBI Special Agent with a large kitchen knife (pictured).' (U.S. Department of Justice)

STATEN ISLAND, N.Y.-- A Mariners Harbor man who allegedly hid a knife in case the FBI showed up has admitted he was trying to help the foreign terrorist group ISIS.

Fareed Mumuni, 22, pleaded guilty to conspiracy to provide material support to ISIS and attempting to murder federal officers during his appearance in Brooklyn federal court Thursday.

"He pled because it's his right," Mumuni's lawyer, Kenneth Montgomery, told the Advance.

Mumuni tried to plunge a kitchen knife into the chest of an FBI special agent executing a search warrant on his Mersereau Avenue home on June 17, 2015, according to federal prosecutors.

The agent survived the attack -- authorities said Mumuni's knife couldn't get through the agent's body armor.

"By lunging with a knife, I knew that if I succeeded I could kill him," Mumuni said, according to Reuters.

"The defendant used a deadly or dangerous weapon to commit such acts," federal prosecutors said.

He was arrested that day, and later pleaded not guilty to providing material support to ISIS and conspiring to assault federal officers.

On Thursday, Mumuni, a U.S. citizen originally from Ghana, also pleaded guilty to conspiracy to assault federal officers, attempting to provide material support to a foreign terrorist organization and assault on federal officers, said prosecutors.

According to the initial complaint against him, Mumuni had "pledged allegiance" to the Islamic State group and kept a knife in case the FBI showed up.

In court, Mumuni said he discussed traveling overseas to join the Islamic State, Reuters reported.

Mumuni's co-defendant, Munther Omar Saleh, of Queens, is expected to plead guilty Friday in Brooklyn federal court, according to a court spokesman.

Saleh is accused of charging, knife in hand, at a law enforcement officer on June 13. He's also accused of plotting to build and detonate pressure-cooker bombs.

Saleh was a student at Vaughn College of Aeronautics and Technology in Queens, and Mumuni was studying sociology and anthropology at the College of Staten Island.

Mumuni will be sentenced May 16 and is facing up to 85 years in prison.