Two teens accused of trying to ignite homemade explosive devices at a protest outside Gracie Mansion over the weekend expressed support for ISIS after their arrest, according to a criminal complaint released Monday.

Emir Balat, 18, and Ibrahim Kayumi, 19, both from Pennsylvania, are suspected of bringing jars filled with nuts, bolts and an explosive material called TATP to the Upper East Side protest, the complaint states. Prosecutors said they both made statements referring to ISIS after police arrested them at the scene. The two had been among a crowd of counterprotestors there in opposition to far-right influencer Jake Lang's anti-Muslim demonstration near the mayor's mansion.

Photos in the federal complaint show Emir Balat holding an improvised explosive device, according to prosecutors.

Balat and Kayumi appeared on a handful of federal charges in a lower Manhattan courtroom Monday, including attempted support of a foreign terrorist organization and use of a weapon of mass destruction. As they were escorted into the courtroom in white jail jumpsuits with their hands cuffed, Balat appeared to be whispering to himself. The teens did not speak during the presentment, and they did not enter a plea.

Judge Gary Stein ordered that Balat and Kayumi be held in jail while they await trial. Their defense attorneys told the judge they might request bail at a later date. Defense attorneys also asked the judge to order that they be held in protective custody.

A man flees from police at a protest near Gracie Mansion. Police said he threw a homemade explosive device.

Balat lit and threw one of the improvised explosives into the crowd, according to the complaint. Police also said they found a second device nearby. A third device recovered several blocks away tested negative for explosive materials, NYPD Commissioner Jessica Tisch said Monday.

The 10-page complaint includes photos of Balat and Kayumi holding black objects in their hands. In one photo, Balat holds one of the devices as a flame burns from the top of it, and another photo shows him holding the device over his shoulder just before he throws it, according to prosecutors.

Balat told investigators that he wanted to carry out an attack bigger than the Boston Marathon bombing and said in a police car that “this isn’t a religion that just stands when people talk about the blessed name of the prophet. We take action,” according to the complaint. At the police precinct, he waived his right to remain silent and wrote on a piece of paper: “I pledge my allegience [sic] to the Islamic State,” the complaint states.

The NYPD wrestles a man to the ground amid a protest near Gracie Mansion.

As Kayumi was being arrested, someone asked why he had done what he had done, and he responded, “ISIS,” the complaint says police body camera footage recorded. He also told police that he was affiliated with ISIS and watched ISIS propaganda on his phone, the complaint states. During an interview with police, Kayumi said he would not feel comfortable if the devices were in the interrogation room with him, the complaint states.

Rebecca Weiner, the NYPD’s deputy commissioner for intelligence and counterterrorism, said at a press conference Monday that young people becoming radicalized on the internet is an issue police officials are tracking closely.

“This is taking place against the backdrop of social media, the dynamics of online culture,” Weiner said. “It’s not limited to ISIS, it’s across the ideological spectrum.”

Tisch said one of the homemade bombs contained TATP, a “dangerous and highly volatile” substance that has been used in improvised explosive attacks across the world. She said the device could cause “devastating harm” and that it was the first time such a device had been used to target people in New York City since 2017. She also said the NYPD has been on high alert since the start of the war in Iran and has ramped up its counterterrorism efforts.

The FBI said Monday evening that agents were conducting a court-authorized search of a storage unit in Pennsylvania connected to the investigation. The search was being carried out by the FBI’s New York Joint Terrorism Task Force with assistance from the NYPD, according to the bureau.

Bob Morhard, an explosives expert, said TATP is an explosive mixture that can detonate very easily and is commonly used by bomb makers in attacks because the ingredients are available in hardware stores.

“TATP is extremely sensitive to friction, heat and shock. And it’s very unstable compared to normal commercial industrial explosives or military explosives,” Morhard said. “Even small amounts can detonate accidentally.”

Attackers have used TATP explosive devices in a number of incidents in recent years, including the 2015 attack in Paris at the Bataclan music venue and the 2005 London bombings, he said.

Correction: An earlier version of this story incorrectly stated the number of homemade explosive devices that authorities say contained TATP. One device contained the substance, according to federal authorities. They said other was not tested before it was detonated by the NYPD.

This story has been updated with new information from the FBI.