In a case tied to weekend clashes outside Mayor Zohran Mamdani’s residence in New York City, prosecutors said two men accused of throwing homemade explosives told authorities they were inspired by the Islamic State extremist group. The allegations come from a court complaint filed after Emir Balat, 18, and Ibrahim Kayumi, 19, were arrested and held without bail following their Monday court appearance, according to the complaint.

The complaint said the men hurled homemade devices—devices that did not explode—during confrontations between counterprotesters and a far-right anti-Islam demonstration led by Jake Lang. Lang has criticized Mamdani, a Democrat and the first Muslim to hold the office, and he was heckled during Mamdani’s news media appearance Monday at Gracie Mansion, the mayoral residence, the Associated Press reported.

FBI New York chief James Barnacle, speaking after the brief court session, described the allegations as an attempt to terrorize people in the backyard of an elected city official. “Balat and Kayumi sought to incite fear and mass suffering through this alleged attempted terror attack in the backyard of an elected city official,” Barnacle said at a news conference, according to the report.

The court filing also addressed what authorities said the men told investigators as they were arrested on Saturday. According to the complaint, Kayumi “blurted out” that “ISIS” was the reason for his conduct, and Balat later told authorities he had pledged allegiance to the extremists, while Kayumi told authorities he was affiliated with the group.

The complaint said officers questioned Balat about whether he intended to replicate an attack like the 2013 Boston Marathon bombing that killed three people and wounded hundreds more. “No, even bigger,” Balat replied, according to the complaint, and both defendants, the report said, remained silent in court as the judge read portions of the allegation.

Balat’s lawyer, Mehdi Essmidi, said outside court that Balat is a Philadelphia-area high school senior with “complicated stuff going on” in his personal life, adding, “There’s a lot to figure out.” Essmidi also said he did not believe the two men knew each other, saying, “They are not known to each other. They do not live together. They did not have friendly, family or school ties,” and that he did not know “how well they knew each other at the time of this incident.”

Kayumi’s lawyer, Michael Arthus, pressed a different concern, pointing to the publicity surrounding the case and asking prosecutors to avoid statements that could prejudice potential jurors. The report said the FBI conducted multiple searches related to the investigation, including a Pennsylvania storage unit, and that police commissioner Jessica Tisch said neither defendant had a criminal history.

Authorities said the incident was not linked to the ongoing war in Iran, Tisch said, and the complaint described how investigators tracked the defendants’ movements. An automated license plate reader captured the men entering New York City from New Jersey less than an hour before the noon-time incident, according to the complaint, and Kayumi’s mother filed a missing person report saying she last saw him around 10:30 a.m. Saturday.

The complaint said Balat tossed a jar-sized device containing the explosive TATP into the crowd as counterprotests escalated. It said the device extinguished itself steps from police officers, and that Balat ran to collect a second, similar device from Kayumi before police arrested both men. The report said the second device had yet to be tested for explosives, and that police tackled Balat after he tried to run away.

Federal and local officials publicly tied the case to extremism and deterrence. U.S. Attorney General Pam Bondi commented on social media that authorities “will not allow ISIS’s poisonous, anti-American ideology to threaten this nation,” according to the Associated Press report, and Manhattan-based U.S. Attorney Jay Clayton said at a Monday news conference that “Violence that is meant to chill free speech, violence that is meant to keep us from assembling peaceably, will be met with swift justice.”

Meanwhile, the scene had grown chaotic even before the devices were thrown. Police said one person involved in Lang’s anti-Islam demonstration, Ian McGinnis, 21, was arrested after he pepper-sprayed counterprotesters. The report said McGinnis, of Philadelphia, was released without bond after pleading not guilty Sunday to assault and aggravated harassment in a New York court, and that his attorney said he was defending himself from counterprotesters.

It was not immediately clear from the complaint what the next procedural steps would be for the two suspects, but the report said their lawyers did not argue for bail Monday though they could do so later. A home listed as belonging to Kayumi’s relative in Newtown, Pennsylvania, had no one available to comment, and neighbors near Langhorne, Pennsylvania, where Balat was said to live, declined to speak when contacted, according to the Associated Press.