A student with autism has been sentenced to 15 years in prison for planting a homemade bomb on a London underground train during morning rush hour.

Damon Smith, 20, constructed the rucksack bomb according to instructions in an online magazine linked to al-Qaida. Filled with ball-bearing shrapnel and using a £2 clock from Tesco as an improvised timer, the devise did not go off.

On Friday morning, he smiled in the dock at the Old Bailey in London as the judge, Richard Marks QC, sentenced him to 15 years in a young offender institution, with an extended period of five years on licence. Marks said although Smith had an interest in Islam, he was not motivated by terrorism.

Smith had pleaded guilty to perpetrating a bomb hoax, claiming he intended the device to work as a smoke bomb to stop the train “for a bit of fun”. But after a five-day trial, he was found guilty on 3 May of possession of an explosive substance with intent, contrary to the 1883 Explosive Substances Act.

Sentencing him, Marks said: “Quite what your motives were and what your true thinking was in acting as you did is difficult to discern with any degree of clarity or certainty.

“Whatever the position, the seriousness of what you did cannot be overstated, not least against the background of the fear in which we all live from the use of bombs here and around the world, an all too timely reminder of which were the events in Manchester earlier this week.”

Smith has Asperger syndrome and had a keen interest in weapons, which might have been connected to his condition, the jury was told during his trial. He was also interested in gambling and Islam, and had collected photos of extremists, including the ringleader of the 2015 Paris attacks.

He was 19 and studying forensic computing at London Metropolitan University when he left the rucksack containing the bomb on a Jubilee line train on the morning of 20 October 2016. Passengers discovered the device and alerted the driver, triggering a major security alert. Smith built the bomb after reading an article entitled How To Build a Bomb in the Kitchen of your Mum.

The jury heard that had the device worked, it would have detonated as people were being evacuated from North Greenwich tube station.

Smith was shot with an electronic stun gun and arrested near Holloway Road in north London the following day. Counter-terrorism officers who subsequently searched his former home in Newton Abbot, Devon, evacuated nearby houses after discovering another possible homemade bomb hidden in the attic.

A search of Smith’s home in Rotherhithe, south-east London, where he had moved with his mother after starting university, found a blank-firing, self-loading pistol and a BB gun, both bought legally, as well as a knuckleduster and a knife that he had showed off in an online video.

Police also found shredded paper with bombmaking instructions on them and a shopping list for “pressure cooker bomb materials” on an iPad he used. The note included a reminder to “keep this a secret between me and Allah #InspireTheBelievers”.

Smith’s barrister, Richard Carey-Hughes QC, said in mitigation that it was a tragic case for Smith and his mother. “This is a difficult climate to ask for mercy for someone convicted of this type of offence,” he said, referring to the suicide bombing at a concert in Manchester on Monday that killed 22 people.

“Nevertheless, we do so and we invite my lord to extend mercy. This case is different. It seems unique and so is this young man.”

In his defence, extracts of a psychiatric report were read out confirming an autism spectrum disorder. Smith had been interested in bombmaking since he was 10 and said it was “something to do when he was bored”.

On the first day of his trial, the judge asked the jury to disregard Smith’s smile as he listened to the prosecution outline the case against him. Smith was “acutely aware that he’s presenting himself in a manner that is odd and unsympathetic”, Carey-Hughes said. On the last full day of his trial, he declined to go into the witness box.

But Marks concluded that Smith was a dangerous offender, telling him: “I am influenced by your history of preoccupation with weapons and bombs, as well as by your condition, which makes it difficult for you to empathise with others and to understand and fully appreciate the very serious potential consequences of your actions, as this incident amply demonstrates.”