CHICAGO — Undercover FBI agents arrested an 18-year-old American man who tried to detonate what he believed was a car bomb outside a downtown Chicago bar, federal prosecutors said Saturday.

Adel Daoud, a U.S. citizen from the Chicago suburb of Hillside, was arrested Friday night in an undercover operation in which agents pretending to be terrorists provided him with a phony car bomb.

The U.S. Attorney’s Office in Chicago, which announced the arrest Saturday, said the device was harmless and the public was never at risk.

Daoud is charged with attempting to use a weapon of mass destruction and attempting to damage and destroy a building with an explosive.

A woman who answered a call to Daoud’s home in Hillside Saturday who said her name was Hiba and that she was Daoud’s sister declined to discuss Daoud or his arrest.

The FBI began monitoring Daoud after he posted material online about violent jihad and the killing of Americans, federal prosecutors said.

In May, two undercover FBI agents contacted Daoud in response to the postings and exchanged several electronic messages with him in which he expressed an interest in engaging in violent jihad in the United States or abroad, according to an affidavit by an FBI special agent.

Prosecutors said that after being introduced to an undercover FBI agent who claimed to be a terrorist living in New York, Daoud set about identifying 29 potential targets, including military recruiting centers, bars, malls and tourist attractions in Chicago.