A teenage asylum seeker told British authorities he had been trained by Islamic State "to kill" before he allegedly planted a bomb on the Tube at Parsons Green in England, a court has heard.
Iraqi Ahmed Hassan, 18, is accused of packing shrapnel into a device containing 400g of TATP then leaving it to go off on a timer at the west London station during rush hour on September 15 last year.
There were 93 commuters on board when the District Line carriage turned into a "furnace engulfed in flames", leaving many with serious burns or crushed in the stampede to get away.
Prosecutor Alison Morgan told jurors: "Had the device fully detonated, it is inevitable that serious injury and significant damage would have been caused within the carriage."
Hassan had arrived in Britain in the back of a lorry via the Channel Tunnel in October 2015 and claimed asylum, saying he was in "fear of Islamic State" because of what happened to him in his home country.
Asked by British Home Office officials in 2016 if he ever had any training with IS, he said: "They trained us on how to kill. It was all religious-based."
He said he was recruited on his own and trained with 1,000 people until Iraqi soldiers came into IS territory and told everyone to go.
He denied he had been sent to Europe to work for IS, the court heard.
Jurors were told that while in the care of Barnados, a member of staff who spoke Arabic caught him listening to a "call to arms" song with lyrics along the lines of: "We are coming with you to the slaughter... in your home/country".
The court heard how Hassan seized a "window of opportunity" to prepare a home-made bomb while his foster parents were on holiday in early September last year.
He researched online how to make explosives, ordering an ingredient on Amazon and using a friend's address to take delivery of the largest component.
The day before he set off from his home in Sunbury, Surrey, England, he bought metal items for shrapnel from Asda and Aldi in Feltham.
The court heard Hassan that had packed the bomb with 2.2kg of screwdrivers, knives and nails to cause "maximum carnage".
On September 15, the defendant left his home shortly before 7am and took the train from Sunbury to Wimbledon, walking by schoolchildren and commuters carrying his bomb, jurors heard.
In the privacy of the toilet in the concourse, he set the timer before boarding the District Line and getting off at Putney Bridge, one stop before Parsons Green.
Ms Morgan told jurors: "At any point, should he have wanted to, he could have stopped the timer. He could have pulled the wires out of the device. He could have stopped the detonation.
"The CCTV footage from inside the carriage shows that at no stage did the defendant reach inside the bag to do anything."
An expert concluded it was "a matter of luck" that the bomb did not fully explode.
The initiator could have come loose when it was transported or the device may not have been well constructed, the court heard.
Passenger Jelena Semenjuk had noticed a bag on the floor and a man fitting the description of Hassan before she heard a "loud bang" and noticed her coat was on fire, the court heard.
She suffered burns to her legs, hands, and face, causing her eyebrows and lashes to be singed off, the court heard.
Aimee Colville saw "shards of glass flying through the air and then flames".
Then she could "smell herself burning and saw her hair was on fire".
Stephen Nash noticed a "blinding light and the feeling that he was in a furnace engulfed in flames", the court was told.
Hassan searched the BBC website for news of the bombing as he fled to Dover after changing into a Chelsea shirt.
When he was arrested at the Kent port, he had £2,320 in cash and told police he was responsible for the device.
Hassan denies attempted murder and using the chemical compound TATP to cause an explosion that was likely to endanger life on September 15 last year.