In 1878 Montenegro was recognised as an independent and sovereign principality by the Congress of Berlin.
The 1912-13 Balkan wars against Turkey, followed by the Treaty of London, brought Montenegro more territorial gains on the Albanian and Kosovan borders. In the First World War, Montenegro fought on the side of the Allies but was defeated and occupied by Austria. King Nikola I and his government went into exile and, in 1918, an Assembly in Podgorica deposed Nikola I and declared Montenegro part of the new 'Kingdom of Serbs, Croats and Slovenes' under a Serbian King, a move that was resisted by some Montenegrins. The new state was renamed the 'Kingdom of Yugoslavia' in 1929.
During the Second World War, in April 1941, Yugoslavia was invaded and partitioned by the Axis powers, with Montenegro falling under the control of the Italians. However, Montenegro's mountainous interior and the strength of the local Communist Party made it an ideal operating base for the Partisans.
When Yugoslavia emerged in 1945 as a socialist federation, under the communist partisan leader Josip Broz (Tito), Montenegro was granted the status of a republic, along with Croatia, Bosnia and Herzegovina, Slovenia, Serbia and Macedonia. Tito ruled the Socialist Federal Republic of Yugoslavia (SFRY) for 35 years, sharing power amongst Yugoslavia's constituent nations.