LONDON (AP) — A teenage Iraqi asylum-seeker who told police he had been trained by the Islamic State group was convicted of attempted murder on Friday for planting a home-made bomb on a London subway train.

Ahmed Hassan, 18, showed no emotion as he was found guilty at London’s Central Criminal Court.

The bomb partially exploded on a London Underground train at Parsons Green station on Sept. 15, sending a fireball down the packed carriage that left 23 people with burn injuries. Police say 28 more were hurt in a panicked rush to leave the train.

Prosecutors said there would have been many more injuries and probably deaths if the device had operated properly. Prosecutor Alison Morgan told jurors it was just “a matter of luck” that the bomb didn’t fully detonate.

Hassan admitted building the bomb but denied attempted murder, saying he had not meant for it to explode. On the witness stand he said he only wanted to cause a fire because he was “bored and stressed” and had developed a fantasy about becoming a fugitive.

Prosecutors said Hassan built the device from everyday ingredients, following instructions he found online. He ordered hydrogen peroxide and other chemicals to make the explosive TATP, and bought nuts, bolts and knives for shrapnel at supermarkets.

He set a timer and left the bomb, inside a white bucket wrapped in a plastic supermarket bag, aboard a London Underground train during the morning rush hour. Hassan got off the train one stop before it exploded.

The teenager left northern Iraq and arrived in Britain in 2015 after traveling across Turkey and Europe and stowing away on a truck through the Channel Tunnel. He claimed asylum and was living with a foster family near London and attending a college before the attack.

British authorities have been criticized for failing to foresee that Hassan, who had shown signs of depression and trauma, might act violently. During a January 2016 immigration interview, he told officials that he was recruited by IS in Iraq and forced to train with them.

“They trained us how to kill. It was all religious based,” he said.

In court, Hassan claimed he had made up the claim about IS to increase his chances of getting asylum in Britain.

He told a teacher at his college that he a “duty to hate Britain,” because he blamed it for a bomb that killed his father in Iraq more than a decade before. The teacher referred him to Prevent, a government-run de-radicalization program.

Commander Dean Haydon, head of the Metropolitan Police Counterterrorism Command, said Hassan was “devious and cunning.”

Haydon said Hassan appeared to engage with the de-radicalization program, “but he kept secret what he was planning and plotting.”

Hassan will be sentenced next week. He faces a maximum of life in prison.