Sentencing Mahmood, the judge said: “The prosecution say you deliberately saved this video to your phone.

“You must have understood the nature of the video. Its visuals and subtitles made clear it was a bomb-making guide, not an innocuous clip.”

The judge said police also found an “alarming display of medieval weapons” in Mahmood’s bedroom.

These included swords, knives, an axe and a catapult, which the defendant claimed were linked to his interest in Islamic history.

While there was no evidence Mahmood intended to use the bomb-making video for a specific terrorist act, the judge said the ballbearings found in his bedroom suggested the defendant was “at least contemplating assembling such a device”.

“You had terrorist motivations. That is clear from the items in your bedroom, the material on your phone and your evidence,” Mahmood was told.

The judge added: “The presence of such an arsenal in the bedroom of an 18-year-old was a clear warning sign – one that regrettably no responsible adult acted upon.”