COPENHAGEN, Denmark -- An Uzbek man who drove a stolen truck into a crowd in Stockholm, killing five people and wounding 14 others, was convicted Thursday of terror-related murder and given a life sentence. Rakmat Akilov had said he wanted to punish Sweden for joining a coalition against the Islamic State of Iraq and Syria (ISIS).

In January, he was charged with terror-related murder and attempted murder for the attack with a beer truck on April 7, 2017.

Those killed were a British man, a Belgian woman and three Swedes, including an 11-year-old girl.

Judge Ragnar Palmkvist said Akilov, 40, was the only suspect in the attack. Prosecutor Hans Ihrman called him a "security risk to society" during his trial at the Stockholm District Court.

Get Breaking News Delivered to Your Inbox

The prosecution had demanded a life sentence while defense lawyer Johan Eriksson said his client had been cooperative throughout the investigation and should be given a lesser sentence.

Palmkvist said the fact that Akilov had been cooperative and had confessed didn't have any influence on the lifetime sentence, which is the heaviest penalty in Sweden and is normally about 18 years. The court sentenced Akilov to be expelled from Sweden after he serves his sentence and banned him from returning.

In this file photo dated April 7, 2017, provided by Swedish Police on Tuesday Jan. 30, 2018, Akhmat Akilov is apprehended in Marsta, north of Stockholm, Sweden, after he drove a stolen truck into a crowd, killing five. AP

After ploughing the truck into a crowd on a busy shopping street and crashing into the upscale Ahlens department store in central Stockholm, Akilov also planned to blow himself up. He failed, and caused a smaller explosion inside the truck. He then fled via the subway but was arrested hours later.

He was found guilty of five counts of terror-related murder, 119 counts of attempted murder and 24 cases of endangering the life of others.

Akilov was born in Uzbekistan and worked there as a construction worker. He came to Sweden in 2014 and applied for asylum, claiming he had been persecuted. His application was rejected and he was ordered to leave Sweden in December 2016.

Instead, he went underground, eluding authorities' attempts to track him down. Sweden's domestic intelligence agency has said it had nothing indicating that he was planning an attack.

On April 6 -- the eve of the attack -- Akilov swore allegiance to ISIS. During the trial, evidence showed how Akilov used 53 SIM cards and social media -- including WhatsApp, Telegram, Viber, Facebook and Zello -- to communicate with others about his activities.

Akilov has said he proposed carrying out an attack in Stockholm to ISIS on their behalf. It was not clear whether the group had accepted his offer.

Investigators have found internet chat logs with unknown people in which Akilov discussed becoming a martyr. They have also found a memory card with execution videos and thousands of photos, including one of ISIS leader Abu Bakr al-Baghdadi.