A 39-year-old Uzbek asylum seeker who confessed to an April 2017 Stockholm truck attack that killed five people planned his assault “against infidels” in Sweden for months, prosecutors said on Tuesday.

A Swedish police hand out shows Akhmat Akilov being apprehended in Marsta, north of Stockholm, after he drove a lorry into a crowd. Swedish Police/TT via AP

Rakhmat Akilov, who swore allegiance to the ISIL prior to the attack, has admitted to stealing a truck and mowing down a crowd of people on a pedestrian street on a Friday afternoon.

Prosecutors formally charged him on Tuesday with “terrorism and attempted terrorism”.

Akilov wanted to “instigate fear among the public in Sweden and force its government and parliament to end Sweden’s participation in military training of the global coalition against ISIL in Iraq,” the indictment said.

ISIL has, however, never claimed responsibility for the attack.

Arrested a few hours after the assault thanks to video surveillance images, Akilov confessed to police the next day.

The prosecution said it would present as evidence excerpts of Akilov’s chat conversations concerning his “willingness to carry out a terror attack” and his “desire to join IS”.

In one chat, Akilov asked for help “to carry out a crime, he wanted to run down infidels (because) Sweden supports NATO and sends bomb technicians to Iraq and train Kurds,” the indictment read.

Prosecutors, who will argue Akilov acted alone, will also present two videos recorded on the eve of the attack in which Akilov swore allegiance to ISIL.

It was still not known why Akilov became radicalised, but “he wasn’t radicalised right before the attack,” prosecutor Hans Ihrman said.

The prosecution plans to present as evidence Akilov’s chat texts dating back to January 2017, photos of the area taken with his smartphone ahead of the attack and internet searches for possible targets and bomb materials on his computer.

After crashing the truck into the facade of a department store, Akilov set off an explosive device in the cab of the truck made up of five butane gas canisters, screws, knife blades and metal objects, causing damage to the truck but no injuries, prosecutors said.

He then fled the scene.

“His motive was to punish Sweden for its participation in the war against IS,” Mr Ihrman told reporters.

Akilov’s lawyer Johan Eriksson told reporters his client would explain his motives further during the trial.

“He admits committing a terrorist act” and "admits that he should be convicted” and expelled from Sweden after serving his sentence, Mr Eriksson said, adding that Akilov had not expected to survive the attack.

“He thought he would be shot or would die.”The Stockholm district court announced Tuesday the trial would start on February 13.

Akilov faces a life sentence if convicted.

A construction worker, Akilov had gone underground after his application for Swedish residency was rejected in 2016, police said last year.

Three Swedes, including an 11-year-old girl, a 41-year old British man, and a 31-year-old Belgian woman were killed in the attack. Around 10 others were injured.

Similar assaults with vehicles have taken place in Europe in recent years, including Berlin, London and the southern French city of Nice, where 86 people were killed and more than 400 were injured on July 14, 2016.

That attack was claimed by ISIL.