Fareed Mumuni, 21, lunged at the agent with a large kitchen knife when he and other members of the Joint Terrorism Task Force showed up with a search warrant about 6:30 a.m. at his home on Mersereau Avenue, according to the Brooklyn U.S. Attorney's office.
Mumuni continued to try to stab the agent in the torso and also attempted to reach for another law enforcement officer's gun during the melee, according to a federal complaint.
FBI agents and police officers eventually disarmed Mumuni and arrested him.
The officers only suffered minor injuries, according to prosecutors.
Mumuni told inspectors that he had planned to go to ISIS-controlled territories in order to join the terror group but if that did not pan out, he had intended to attack members of law enforcement. He also told them that Wednesday's attack was premeditated and that he kept a knife wrapped in a T-shirt by his bed to use on law enforcement agents.
The officers also recovered a duffel bag with another kitchen knife in Mumuni's mother car, which he sometimes used, according to the criminal complaint.
Mumuni is the third New York man arrested for allegedly planning a terror attack in the city in less than a week.
He was in touch with Munther Omar Saleh, a Queens College student, who was arrested with a co-conspirator, whose name was not released, on June 13 after they also tried to attack law enforcement officers with a knife.
Saleh had been watched for several months when he was arrested for planning a terrorist attack in the city and pledging allegiance to ISIS, prosecutors charged.
In May, Saleh emailed himself information on how to build a pressure cooker bomb and him and his co-conspirator, researched what tools were needed to build an explosive device, prosecutors said. He then researched for the city's most notable landmarks and tourist attractions, according to court documents.
Saleh and Mumumi met several times including in lower Manhattan and in Staten Island last May, law enforcement officers said. On June 2, they discussed their plan to attack law enforcement members.
Saleh told Mumuni that the best option would be "to use a bomb and then run over members of law enforcement with a vehicle, seize the weapons of any victims and use the weapons to shoot at other victims," according to the federal complaint.
Ten days later, on June 12, Saleh wrote to Mumuni he had told his parents he would be gone in "much less than a year."
"You have two choices," Saleh wrote to his parents according to the criminal complaint, "either you let me go to Darul Islam [ISIS-controled territories] or you watch me kill nonMuslim here."
Early the next morning, Saleh and his accomplice tried to attack a police officer, each of them carrying a knife, at 20th Avenue near the Whitestone Expressway. The police officer escaped and Saleh and his accomplice were arrested.
Saleh, 20, told inspectors he had pledged allegiance to ISIS and was "full-fledged" member of ISIS. He told prosecutors Mumuni was also a supporter of the terrorist organization and that he had told him he planned to attack law enforcement members too.
Mumuni was scheduled to be arraigned in Brooklyn Federal court on Wednesday and charged with attempted murder a federal employee, which carries a maximum sentence of 20 years of imprisonment, according to court documents.
Mumuni's lawyer, Anthony Ricco, and Saleh's lawyer, Deborah Colson, did not immediately return a request for comment.