In 1102 the previously-independent Kingdom of Croatia and Kingdom of Hungary entered personal union and were ruled by the same King, Ladislaus I. Following the Ottoman conquests and a disastrous defeat at the Battle of Mohács in 1527, Croatian nobility elected the Holy Roman Emperor Ferdinand I as the new king of Croatia. The Hungarian nobility was divided but the Habsburgs annexed the Kingdom of Hungary, keeping Croatia and Hungary under a single crown. During the Hungarian Revolution of 1848 Croatia sided with the Austrians so Croatian Ban Josip Jelačić helped Austria to defeat the Hungarian forces in 1849 and ushering in a period of Germanisation. By the 1860s the failure of this policy became apparent, leading to the Austro-Hungarian Compromise of 1867 and the creation of a personal union between the crowns of the Austrian Empire and the Kingdom of Hungary. The issue of Croatia's status was resolved by the Croatian–Hungarian Settlement of 1868, when the kingdoms of Croatia and Slavonia were united into Kingdom of Croatia-Slavonia. Following the breakup of Austria-Hungary after its defeat in World War I, Croatian Parliament declared independence on 29 October 1918 and decided to join the newly formed State of Slovenes, Croats and Serbs, ending Habsburg rule and the personal union with Hungary after 816 years. Through the Treaty of Trianon, Hungary lost Međimurje County and the southern part of Baranya to Croatia. Since World War II, relations between two states have been defined by cooperation with Nazis, Soviets and Yugoslavia until the revolutions of 1989 and the breakup of Yugoslavia. Hungary recognised Croatian independence with the rest of the European Economic Community in 1992, and supported Croatia during the Croatian War of Independence.