Extremist material including lectures by banned hate preacher Anwar al-Awlaki were discovered in prayer rooms in two London hospitals.
A 17-year-old boy, from Ilford, east London, admitted creating flyers and CDs promoting jihad, and was threatened with prison by a judge at Westminster Magistrates' Court on Thursday (25 January).
The boy pleaded guilty to three offences which the judge said were "very serious".
The material was found in the Royal London Hospital, in Whitechapel, east London, and University College Hospital, in Euston, in central London.
The teenager, who cannot be identified because of his age, was arrested after a carrier bag containing flyers entitled "Go my Muslim brothers and fight for the mujahideen in Chechnya and become martyrs for the sake of Allah" was left on a Tube train in April last year.
The owner of the carrier bag, a man in his 50's, was traced using CCTV and his travel card to Royal London Hospital, where a pile of CDs were found in a cupboard in the prayer and contemplation room.
These CD's marked "Free. Take me" contained sermons by the banned pro-al-Qaeda preacher al-Awlaki, who was killed by a US drone strike in 2011.
Police investigating the man then conducted a search at University College Hospital and discovered further extremist material in the prayer room, reported BBC News.
The link between the unidentified man and the boy is unclear.
DNA evidence linked the material to the 17-year-old boy and a raid at his home, on 11 October last year, found more disks and the computer used to create the flyers.
Senior District Judge Emma Arbuthnot threatened to jail the teenager unless his family can prove that they are doing all they can to stop him reoffending.
"This boy is nearly 18. This is a very serious offence. I'm going to need to know all I can about the family," she said, reported the East London Advertiser.
"If there's no family stopping this from happening I'm going to lock him up, quite frankly."
Adjourning sentencing until 5 March, Arbuthnot added: "I have to make sure that if I don't lock you up there's a very robust package of measures in place. If you were over 18 I would lock you up, no problem."
The boy pleaded guilty to two charges of encouraging and assisting the commission of a terrorist offence between December 2016 and October 2017 and one count of providing a service to assist an act of terrorism.