Ulrika Eleonora was born on 11 September 1656 in Copenhagen, the daughter of Frederick III of Denmark and Sophia Amalia of Brunswick-Lüneburg. In 1675 the Swedish envoy Nils Brahe presented Charles XI's proposal, and she was betrothed. Her brother Christian V first agreed but withdrew his consent soon after the Scanian War broke out, while she herself still regarded herself as betrothed and turned down other marriage plans. During the war she looked after Swedish prisoners of war and pawned her own belongings to get them food, bedding and medicine.
After the peace of 1679 the marriage question was taken up again, and the wedding was held quietly at Skottorp on 6 May 1680. In November 1680 she came to Stockholm, where triumphal gates carried Latin texts praising virtues such as vigilance, patience and piety, and on 25 November she was crowned in Storkyrkan. As queen she is described as devout, patient and gentle, with little political influence. Her relationship with her mother-in-law Hedvig Eleonora was strained. After an open rupture in spring 1686 she left Stockholm in July and moved to Uppsala castle with the children, and in September she was back.
She was known for her charity. She founded a poorhouse on Kungsholmen, the Drottninghuset, and a children's home at Karlberg, and in 1693 she is said to have supported about 17,000 people. The couple had seven children, among them Charles XII. Her health was poor for several years, and around 1690 she fell ill with an illness that was never diagnosed. She died on 26 July 1693, aged 36, at Karlbergs slott in Solna. In autumn 1693 she was buried in Riddarholmskyrkan in Stockholm. She had wished for a simple funeral, but it turned out lavish.
