Oscar II, christened Oscar Fredrik, was born on 21 January 1829 at the Royal Palace in Stockholm, the son of Oscar I and Josephine of Leuchtenberg. At birth he was given the title Duke of Östergötland. He joined the navy at the age of eleven, passed his naval officer's examination on 19 June 1845 and later studied at Uppsala University. In 1857 he married Sophia of Nassau.
On 18 September 1872 he became king of both Sweden and Norway. He was crowned in Storkyrkan on 12 May 1873, the last king to be crowned in Sweden, and in Trondheim Cathedral on 18 July that year. He had Axel Anderberg build a new opera house for the Royal Swedish Opera, inaugurated on 19 September 1898. The king also backed science: he funded the Vega Expedition and made Adolf Erik Nordenskiöld a baron on his return to Stockholm in 1880. He gave up the Norwegian throne on 26 October 1905.
Oscar II died on 8 December 1907 at the Royal Palace. On 13 December he lay in state in the Palace Chapel, the last king to do so in an open coffin. He is buried in Riddarholmskyrkan.
