The singer, who previously triumphed in 2012, made history as the first woman, and only the second person, to win the contest twice.
She scored a total of 583 points after the public and jury votes were combined, narrowly beating Finland’s Kaarija who scored 526.
The win also ties her native Sweden with Ireland as the nation with the most wins, with seven apiece.
It also means the contest will take place in the home nation of Eurovision legends Abba on the 50th anniversary of their win in 1974.
After she was announced as the winner at the M&S Bank Arena, Loreen returned to the stage and was handed the trophy by last year’s winners Kalush Orchestra of Ukraine.
She said: “This is overwhelming. I’m so happy and I’m so thankful.”
Addressing the crowd, she added: “Thank you for this, this is for you.”
Loreen had performed her anthemic dance-pop song Tattoo for the international voting public, singing from an illuminated enclosed space on the stage.
Her win means she equals the record held by Irish singer Johnny Logan, who triumphed at the contest in both 1980 and 1987.
The Ukrainian entry, the brooding electronic duo Tvorchi, scored a total of 243 points and placed sixth in the rankings.
Ukrainian presenter Julia Sanina, who is lead singer of the band The Hardkiss, was hugged by her co-hosts, Britain’s Got Talent judge Alesha Dixon and Ted Lasso star Hannah Waddingham, as the show came to a close.
Dixon said this year’s contest was something “that will live in our hearts for a very long time”.
Loreen then took to the stage to perform her song Tattoo for a second time.
Later, she added: “Not in my wildest dreams did I think this was going to happen.”
There was disappointment for UK entrant Muller who scored only 24 points despite an energetic performance of her track, I Wrote A Song.
Below her on the leaderboard was only Germany’s heavy metal band Lord Of The Lost with 18.
She had hoped to continue the success of last year’s UK entry Sam Ryder, who finished second behind Kalush Orchestra.
— Rishi Sunak (@RishiSunak) May 13, 2023
Commiserations came from the BBC, who organised the contest in partnership with the European Broadcasting Union.
The broadcaster’s official Twitter account posted: “Mae, we’re so proud of you and everything you’ve achieved at this year’s Eurovision Song Contest.”
As the show ended, Prime Minister Rishi Sunak tweeted: “Liverpool, you’ve done the United Kingdom and Ukraine proud.
“What a fantastic celebration for #Eurovision2023 Congratulations @Loreen_Talhaoui. Sweden it’s over to you.”
The grand final on Saturday night featured a series of musical tributes to Ukraine, who would have hosted the contest this year had it not been for the Russian invasion.
The night opened with a pre-recorded video featuring last year’s winners Kalush Orchestra – and a surprise appearance from the Princess of Wales, playing the piano.
They were joined by 2022 runner-up Sam Ryder playing guitar on the top of the Liver Building on the Liverpool waterfront, with Andrew Lloyd Webber on piano.
Former Ukrainian contestants Go_A, Tina Karol and Jamala, who won for Ukraine in 2016, performed in between this year’s hopefuls arriving for the flag parade.
But there was no appearance from Ukrainian president Volodymyr Zelensky, who was barred from addressing the event.
On Thursday, producers the European Broadcasting Union (EBU) said they had declined Mr Zelensky’s request to speak on Saturday over fears it could politicise the contest.
The move prompted criticism from Prime Minister Rishi Sunak and his predecessor Boris Johnson, among other figures.