The song was first sung at a party held by the University of Lund in 1844 to celebrate the accession of the new king, Oscar I. The anthem was used as a national and royal anthem until 1893, when it became solely the royal anthem. It replaced the former anthem “Bevare Gud vår kung” (God Save the King) by Abraham Niclas Edelcrantz, in use since February 12, 1805 which was sung to the tune of not only the British royal and national anthem (also called “God Save the King” when ruled by a male monarch), but also the current tune of the royal anthem of its neighbour, Norway. During the reign of Gustav III (1771-1792) “Gustafs skål” with music and lyrics by Carl Micael Bellman was a favourite of the king, and was informally his royal anthem.
Special thanks to: Dieter Baalss for informing me about this anthem, Reinhard Popp for the sheet music, and Lars C Stolt for some of this information.