The DJ, whose real name was Tim Bergling, was found dead Friday in Muscat, the capital of the Gulf sultanate Oman, where he had been on holiday with friends.
A police source in Oman said his death was not considered to be suspicious, adding that the circumstances would remain confidential at the request of the family.
Tributes poured in from the musical world, including Madonna, as well as from Swedish royalty.
On Saturday afternoon, several thousand people gathered to remember the DJ at Sergels Torg plaza in Stockholm, where the crowd danced to his hit songs.
“He was a modern Mozart,” said 61-year-old language teacher Chris Koskela. “One of the greatest artists that Sweden has ever known.”
Fellow DJ Sebastian Ingrosso, who organised the event with Swedish House Mafia, tweeted: “We were just kids with dreams, Tim inspired us all and millions more.”
Although the circumstances surrounding his death were unclear, the Muscat Hills Resort confirmed that Avicii had recently stayed with them.
It did not say exactly when but other photos on Instagram showed him there earlier this week.
“Avicii definitely did seem to be in good spirits while enjoying his time and he was also very friendly with everyone,” it said on its Instagram account.
“As much as we enjoyed his company here at Muscat Hills Resort, we are extremely sad to hear and read all the recent news and therefore we would like to express our sincere condolences to his family, friends and all his fans.”
It added that it would pay its own tribute to the young Swede with a beach party in his memory on Friday.
On Friday night nightclubs across the capital held a minute’s silence and his name was projected on the Ericsson Globe arena, where in 2014 Avicii played three sell-out gigs.
Madonna, who worked with Avicii on her last album, posted a picture of herself in the DJ booth with him and wrote: “So Tragic. Goodbye Dear Sweet Tim. Gone Too Soon.”
DJ David Guetta, who collaborated with Avicii on “Sunshine,” wrote: “We lost a friend with such a beautiful heart and the world lost an incredibly talented musician
In 2015, Avicii DJ-ed at the wedding reception of Sweden’s Prince Carl Philip and his bride Sofia. In a statement they said: “We had the honour to have known him and admired him both as an artist and the beautiful person that he was.”
– Health problems –
Avicii was among the first DJs to break through into the mainstream as electronic dance music grew over the past decade from nightclubs to Top 40 radio.
His biggest hits included “Wake Me Up,” which went to number one across Europe in 2013 and featured the soul singer Aloe Blacc.
But he had made no secret of his health problems, including pancreatitis, triggered in part by excessive drinking linked to his party lifestyle.
In 2016, Avicii stunned fans by announcing his retirement when he was just 26, saying that he wanted to leave the high-flying electronic music lifestyle.
Avicii — who for years was one of the world’s most lucrative electronic musicians — in 2016 made number 12 on the list of top-paid DJs of Forbes magazine, which said he earned $14.5 million in the previous year.