The duchies of Schleswig and Holstein were located between Denmark and Prussia and had, for much of their history, been dynastically interlinked, and within the gift of the Danish Crown. However, the rules of succession in Schleswig prescribed only male heirs could inherit. When the childless Frederick VII became king of Denmark in 1848, he was pressured by Danish nationalists into annexing Schleswig to pre-empt the rival dynastic claims of the pro-German duke of Augustenburg. The population in northern Schleswig was predominantly Danish, the south was more mixed; Holstein was predominantly German. Rebellions broke out in both duchies led by nationalists supporting the competing claims. Two wars ensued: in the first (1848–51) Denmark prevailed; in the second (1864) Denmark was crushingly defeated by Prussia and its ally Austria. In the Treaty of Vienna that followed, Schleswig was placed under Prussian administration, Holstein under Austrian administration.