The oldest known inhabitants of what is now Montenegro were the Illyrian tribes who were subdued by the Romans in 9AD and then marginalised by the mass immigration of Slavs in the fifth and sixth centuries. The principality of Duklja that the Slavic newcomers founded became independent from the Byzantine Empire in 1042 and soon became a kingdom, expanding to incorporate surrounding areas. In the early medieval era the region was ruled alternatively by local families and the medieval Serbian state until the Ottomans occupied the region in 1499.
The Ottoman era
Montenegro remained relatively autonomous within the Ottoman empire, with local noble families allowed to rule the area with little interference. Despite this, the occupation was never accepted and several uprisings occurred until the Ottomans were finally defeated in the late 17th century. Under Prince-Bishops Petar I and II Petrović-Njegoš, Montenegro unified and became a theocracy.
Nicholas I greatly expanded and modernised the principality in the 20th century, winning recognition of independence from the Ottoman Empire in 1878. The constitution is signed in 1905, the country becomes a kingdom in 1910, and Cetinje quickly became more important as Montenegro's capital, with a succession of embassies established there. Montenegro started the Balkan Wars of 1912 and 1913 to definitely expel the Ottomans from the region, and joined Serbia in the First World War. In 1918, the country was added to Serbia and remained so until the country was invaded and declared independent by the Nazis in 1941. After liberation by Yugoslav partizans in 1944, during which Podgorica was heavily damaged, Montenegro became a republic within the Socialist Federal Republic of Yugoslavia. Podgorica became Titograd in honour of President Josip Tito and the city was rebuilt.
The end of Yugoslavia
Yugoslavia's collapse in 1992 meant that Montenegro was left alone with Serbia in the new Federal Republic of Yugoslavia. An unmonitored referendum at the time showed great support among Montenegrins for this, though turnout was low due to boycotts. The Montenegrin police and military joined Serbian troops in the Bosnian and Croatian wars of 1991-1995 and were involved in various campaigns against towns in Croatia (including the bombing of Dubrovnik) and Bosnia. Prime Minister Milo Đukanović started to cut ties with Serbia in 1996, replacing the dinar with the German Mark (and later the euro) to loosen economic ties with Belgrade and becoming much more independent. During NATO's 1999 Kosovo campaign, Montenegro was also targeted though damage was limited.
While tensions with Serbia remained, Montenegro continued on the path towards separation. The Federal Republic of Yugoslavia was replaced by the union of Serbia and Montenegro in 2003, but soon enough the peaceful and fair EU-monitored referendum in 2006 showed a 55% majority in favour of complete independence from Serbia. Montenegro subsequently became independent on June 3, 2006. Tensions remain as Montenegrin and Serbian identity are closely interwoven.
Since independence Montenegro has seen great economic growth, particularly in the tourism and construction sectors as a liberal land ownership policy allowed foreigners to buy land with few restrictions. Especially Russian investors took advantage of the opportunity, and Budva and other coastal resorts see many Russian tourists in summer. The economy took a hit during the world financial crisis and tourism numbers dropped, though long-term prospects are still good.