Sweden participated in and won the Eurovision Song Contest 2012 with the song "Euphoria" written by Thomas G:son and Peter Boström. The song was performed by Loreen. The Swedish broadcaster Sveriges Television (SVT) organised the national final Melodifestivalen 2012 in order to select the Swedish entry for the 2012 contest in Baku, Azerbaijan. After a six-week-long competition consisting of four heats, a Second Chance round and a final, "Euphoria" performed by Loreen emerged as the winner after achieving the highest score following the combination of votes from eleven international jury groups and a public vote.
 Sweden was drawn to compete in the second semi-final of the Eurovision Song Contest which took place on 24 May 2012. Performing during the show in position 11, "Euphoria" was announced among the top 10 entries of the second semi-final and therefore qualified to compete in the final on 26 May. It was later revealed that Sweden placed first out of the 18 participating countries in the semi-final with 181 points. In the final, Sweden performed in position 17 and placed first out of the 26 participating countries, winning the contest with 372 points. This was Sweden's fifth win in the Eurovision Song Contest, having previously won in 1974, 1984, 1991 and 1999.
 Prior to the 2012 contest, Sweden had participated in the Eurovision Song Contest fifty-one times since its first entry in 1958. Sweden had won the contest on four occasions: in 1974 with the song "Waterloo" performed by ABBA, in 1984 with the song "Diggi-Loo Diggi-Ley" performed by Herreys, in 1991 with the song "Fångad av en stormvind" performed by Carola, and in 1999 with the song "Take Me to Your Heaven" performed by Charlotte Nilsson. Following the introduction of semi-finals for the 2004, Sweden's entries, to this point, have featured in every final except for 2010 when the nation failed to qualify. In 2011, Sweden placed third in the contest with the song "Popular" performed by Eric Saade.
 The Swedish national broadcaster, Sveriges Television (SVT), broadcasts the event within Sweden and organises the selection process for the nation's entry. Since 1959, SVT has organised the annual competition Melodifestivalen in order to select the Swedish entry for the Eurovision Song Contest.
 Melodifestivalen 2012 was the Swedish music competition that selected Sweden's entry for the Eurovision Song Contest 2012. 32 songs competed in a six-week-long process which consisted of four heats on 4, 11, 18 and 25 February 2012, a second chance round on 3 March 2012, and a final on 10 March 2012. The six shows were hosted by Sarah Dawn Finer, Gina Dirawi and Helena Bergström. Eight songs competed in each heat—the top two qualified directly to the final, while the third and fourth placed songs qualified to the second chance round. The bottom four songs in each heat were eliminated from the competition. An additional two songs qualified to the final from the second chance round. The results in the heats and second chance round were determined exclusively by public televoting, while the overall winner of the competition was selected in the final through the combination of a public vote and the votes from eleven international jury groups. Among the competing artists were former Eurovision Song Contest contestants Lotta Engberg (participating as a duet with Christer Sjögren) who represented Sweden in 1987, Charlotte Perrelli who represented Sweden in 1999 (which she won) and 2008, Afro-Dite who represented Sweden in 2002 and Andreas Lundstedt who represented Switzerland in 2006. Molly Sandén represented Sweden in the Junior Eurovision Song Contest 2006.
 The final was held on 10 March 2012 at the Globe Arena in Stockholm. Ten songs competed—two qualifiers from each of the four preceding heats and two qualifiers from the Second Chance round. The combination of points from a viewer vote and eleven international jury groups determined the winner. The viewers and the juries each had a total of 473 points to award. The nations that comprised the international jury were Belgium, Bosnia and Herzegovina, Cyprus, Estonia, France, Germany, Ireland, Malta, Norway, Ukraine and the United Kingdom. "Euphoria" performed by Loreen was selected as the winner with 268 points.
 Sweden competed in the second half of the second semi-final in Baku on 24 May 2012, following Croatia and preceding Georgia. Loreen received 181 points and placed 1st, thus qualifying for the final on 26 May. The public awarded Sweden 1st place with 180 points and the jury awarded 1st place with 148 points.
 In the final, Sweden was drawn to have performed 17th, after Greece and preceding Turkey. The Swedish entry received votes from 40 countries and won the contest, with only Italy failing to award them any points. Loreen scored a total of 372 points, the second-highest winning score in the contest's history after Norway's 387 point win in 2009. Sweden received a record set of 12 points from 18 countries. The public awarded Sweden 1st place with 343 points and the jury awarded 1st place with 296 points. This was the fifth win for Sweden at the Contest.
 The Swedish entry was awarded two of the three Marcel Bezençon Awards, which honour the best of the competing entries for the 2012 contest in different areas of achievement. The Artistic Award was presented to the best artist as voted by the commentators and the Composer Award was the best and most original composition as voted on by the participating composers. Loreen's performance in the contest was directed by Swedish choreographer Ambra Succi.