The suspect behind the Stockholm truck attack had been facing deportation and had extremist sympathies, Swedish police say.
The 39-year-old Uzbek man - named in Swedish media as Rakhmat Akilov - is suspected of having driven a truck into a city department store on Friday.
His application for residency was rejected in June last year and he was being sought by immigration officials.
Meanwhile, a second suspect has been placed under formal arrest.
Police, who have not formally named Mr Akilov as the first suspect, said they were investigating the second suspect for a "terrorist crime [by committing] murder".
However, Reuters news agency said the person was arrested on "a lower degree of suspicion" than the first suspect.
Police have interviewed more than 500 people over the incident, Sweden's TT news agency reports.
On Sunday, people gathered in central Stockholm for a "Lovefest" vigil against terrorism, and laid flowers outside the Ahlens shop in tribute.
More than 20,000 people attended the vigil, AFP reported, citing city officials.
City mayor Karin Wanngard told the crowds: "Terror cannot win... instead we shall think of the kindness and openness that characterises our city."
Mr Akilov had applied for permanent residency in 2014, but this was rejected, and in December 2016 he was given four weeks to leave the country, police chief Jonas Hysing told a press conference.
The suspect then disappeared, and police began searching for him, Mr Hysing added.
He was known to have expressed sympathy for groups including so-called Islamic State, but had been seen only as a "marginal character", police said.
Four people are confirmed to have died in the attack. Police have not released their identities, but said they were:
- Two Swedish nationals - one reported to be an 11-year-old girl
- A Briton - named by his family as 41-year-old Chris Bevington
- A Belgian woman, said to be a 31-year-old from the city of Halle
Another 15 people were injured.
The truck, hijacked from a beer company, was driven into Ahlens department store in the capital on Friday afternoon.
No terrorist group has claimed to be behind the attack.
Sweden has taken in nearly 200,000 refugees and migrants in recent years - more per capita than any other European country.
However, there was a drop in numbers last year after the country introduced new border checks.
Separately, Sweden is believed to have the highest number of Islamic State group fighters per capita in Europe.
About 140 of the 300 who went to Syria and Iraq have since returned, leaving the authorities to grapple with how best to reintegrate them into society.