Swedish police said Saturday that they believe they have captured the man accused of turning a beer truck into a weapon a day earlier by driving it into a crowd of pedestrians in a rampage that left four people dead.

Authorities did not divulge the man’s name but said he is a 39-year-old from Uzbekistan who had been known to security services as “a marginal character” for the past year. Police said that when they first investigated him, they had found no connections to extremism. Authorities did not say when the man had come to Sweden.

The arrest came Friday night when officers apprehended a suspect in the northern Stockholm suburbs who matched the description of a man seen in surveillance footage earlier in the day. Police initially said they were unsure whether the man they had arrested was involved in the attack.

But their confidence grew overnight, and in an early afternoon news conference Saturday, authorities said they were all but certain that they had caught the assailant.

Swedish Prime Minister Stefan Lofven said Friday that the attack was “an act of terrorism,” although officials have not commented on an exact motive.

1 of 10 Full Screen Autoplay Close Skip Ad × The scene in Stockholm after a truck crashed into a store, killing at least 3 View Photos An apparent stolen truck crashed into a department store, killing at least three people in what the country’s prime minister called a “terror attack.” Caption An apparent stolen truck crashed into a department store, killing at least three people in what the country’s prime minister called a “terror attack.” April 7, 2017 A truck crashed into the Ahlens department store at Drottninggatan in central Stockholm, Sweden. Jonathan Nackstrand/AFP/Getty Images Buy Photo Wait 1 second to continue.

Swedish media outlets reported Saturday that there was a homemade explosive device discovered in the mangled wreckage of the truck, which was towed overnight from the upscale shopping district that on Friday afternoon became a scene of carnage.

National Police Chief Dan Eliasson said that “a device that did not belong there was found in the truck.” But officials said it was unclear whether it was a bomb.

Flags across Stockholm flew at half-staff Saturday, and mourners paid respects by leaving flowers at the scene of the attack.

Among them were Crown Princess Victoria and her husband, Prince Daniel. With tears in her eyes, Victoria said she was filled with “sadness and emptiness.”

In nationally broadcast remarks, King Carl XVI Gustaf — who returned home from a visit to Brazil following the attack — said his thoughts “go out to the victims of this abhorrent deed, fellow humans who have been injured and killed.”

Politicians across the spectrum also paid tribute to the dead, and many expressed backing for the prime minister’s handling of the incident. A Facebook-organized remembrance for the victims is due to be held near the scene of the crime on Sunday.

With the attack, which also injured 15 others, Stockholm joined a growing list of major European cities where vehicles have been turned into weapons over the past year, including Nice, France, Berlin and London.

Despite the growing frequency of such attacks, security officials say there are few obvious solutions because it is nearly impossible to stop an assailant determined to drive into pedestrians.

Fredrik Reinfeldt, a former Swedish prime minister, told the BBC on Saturday that the country would continue to try to thwart such attacks, but would not compromise its values.

“We are preparing, we understand the risks,” he said. “But we are not willing to close down the openness that is the flare of freedom that we love so much.”

Read more:

[It’s nearly impossible to stop terrorists from using trucks as weapons. But cities are trying.]

[How vehicles became a tool of terrorism]

Today’s coverage from Post correspondents around the world

Like Washington Post World on Facebook and stay updated on foreign news