FBI agents have arrested an 18-year-old who they say planned to set off a car bomb outside a bar in the centre of Chicago.
Adel Daoud, a male US citizen from Chicago, was detained in an undercover operation on Friday in which agents pretending to be extremists provided him with a fake car bomb.
The US Attorney's Office in Chicago insisted the device was harmless and that 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.
The FBI began monitoring Daoud, who lives in the Chicago suburb of Hillside, after he posted material online about violent jihad and the killing of Americans, state prosecutors said.
In May, two undercover 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 US or abroad.
Prosecutors say 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 centres, bars, malls and tourist attractions in Chicago.
Events culminated on Friday when Daoud met with the undercover agent who claimed to be from New York in a Chicago suburb, and the two drove to the city centre, where the restaurants and bars were packed with people on a warm evening.
They then entered a car park where a Jeep Cherokee containing the fake bomb was parked.
According to court documents, Daoud drove the vehicle and parked in front of a bar that was among the pre-selected targets, then walked a block away and attempted to detonate the device by pressing a triggering mechanism in the presence of the agent. He was then arrested.
The bar has not been identified.
Prosecutors said Daoud was offered several chances to change his mind and walk away from the plot.
In his communications with one of the FBI agents about possible targets, the teenager allegedly said he wanted to carry out an attack that would kill a large number of people.
"I wanted something that's ... massive; I want something that's gonna make it in the news," he wrote, according to a court statement.
"I want to get to like, for me I want to get the most evil place, but I want to get a more populated place."