Loreen, 28, wowed voters with a catchy dance number called Euphoria, featuring an upbeat chorus accompanied by a high-kicking dance duet and a storm of artificial snow.
She brandished the glass microphone trophy in a shower of gold ticker-tape at a post-contest news conference. "It's just a question of taste. This year it happened to me," she modestly explained her victory.
She hugged her mother and smiled, referring back to the title of her song as she explained she felt at her win: "I know this sounds corny, but euphoric." The victory brings Eurovision back to one of its heartlands.
Sweden's most famous band Abba gained worldwide fame after winning the contest in 1974 with Waterloo - for many the song that defined the kitschy contest for all time.
"Hallelujah!" exlaimed the head of the Swedish delegation in Baku, Christer Bjorkman at the news conference. Loreen's win took Sweden's total of Eurovision trophies to five, making it one of the most successful countries at winning the quirky contest.
However, it last struck gold more than a decade ago in 1999. Second place on Saturday went to Russia's heartwarming Buranovskiye Babushki, a choir of elderly women from a village who performed a disco song Party for Everybody in English and their local Finno-Ugric language with a stove and a tray as props.
Third was Serbian Eurovision veteran Zelijko Joksimovic who had already competed in three previous contests, once as a singer and twice as a composer. Eurovision is the biggest event ever hosted by energy-rich Azerbaijan as it seeks to present a glitzy front to the world despite the intolerance of dissent and opposition under the rule of the Aliyev dynasty.
The final's 26 acts lit up the spectacular Crystal Hall built to host the contest in barely half a year on the Caspian Sea, with an audience of some 20,000 inside the venue and 100 million television viewers.
The host entry Sabina Babayeva was not all that far from securing a repeat of Azerbaijan's 2011 success that earned the nation the right to host the contest with her When the Music Dies coming in fourth.
Loreen ran into controversy during the contest by meeting local rights activists who briefed her on the lack of democratic freedoms in the tightly controlled ex-Soviet state.
However at a post-contest news conference she sidestepped a question about how she would support the people of Azerbaijan further, saying simply that: "I will support the Azerbaijan people from my heart."
She had earlier declined to comment on her views at a news conference on Thursday, while local opposition media reported that Azerbaijan state television gave a bland mistranslation of the question.
The show itself included the usual range of the weird and exotic including a Norwegian rapper of Iranian origin who came last, half-naked French gymnasts and an Albanian entry with a song solely in her native language and a truly terrifying top note.
There was disappointment for Britain after veteran crooner Engelbert Humperdinck - brought in to revive its notoriously bad Eurovision fortunes - scored just 12 points and came second last with his ballad Love Will Set You Free.
In Baku, the festive atmosphere was clouded by the detentions of dozens of opposition activists who attempted to hold several peaceful demonstrations calling for democratic freedoms in the tightly-controlled state.
The Public Chamber opposition alliance said that more than 60 protestors were detained Friday in the latest protest and a court sentenced three protesters to jail terms of five or six days.
Azerbaijan is run by strongman President Ilham Aliyev, who succeeded his late father Heidar Aliyev in 2003. His wife Mehriban Aliyeva heads the organising committee of Eurovision and his son-in-law, Emin Agalarov, a Moscow-based businessman with a budding pop career, sang in a black leather jacket in a musical interlude after the voting.
Radio Liberty reported this month that a construction company involved in the project to build the Crystal Hall venue in a city-commissioned project had links to the Aliyev family.
The event was also far beyond the reach of ordinary Azerbaijanis, with tickets for the final starting at 160 manat ($204), half the monthly income of the average Azeri according to World Bank statistics.
With political sensitivities never far from this Eurovision, the promotional videos shown included landscapes from Nagorny Karabakh, which Armenian separatists backed by Yerevan seized from Azerbaijan in a war in the 1990s.
Armenia had pulled out of the contest saying it feared hostile treatment and Azerbaijan barred those who had visited Nagorny Karabakh from travelling to the contest.