The ancestors of the Slovenes, who migrated to present-day Slovenia in the 7th century, may not have played a leading role in the major historical events in Europe and the world, but they were always involved.
As late as the 20th century Slovenia was still being ruled by foreigners, mostly the Habsburg monarchy of Austro-Hungary. The Slovene people nevertheless succeeded in forging a collective consciousness and national allegiance. Slovenia became part of the Kingdom of Yugoslavia after the First World War, then part of the Socialist Federal Republic of Yugoslavia after the Second World War. After more than 70 years of living inside Yugoslavia, almost 90% of voters opted for independence in 1990.
The Romans began penetrating the area in the 2nd century BCE. They built major roads, and developed the first cities along these roads, many of which have survived until the present day: Emona (Ljubljana), Celeia (Celje), Poetovio (Ptuj) and Castra (Ajdovščina). Among the most important ruins from this period is the necropolis at Šempeter in the Savinjska Valley.
In the late 4th century a battle took place in Slovenia that was a direct cause of the partition of the Roman empire into two parts. In the 6th century the Slavs settled the area, having migrated from the fringes of the Carpathians. The ancestors of the Slovenes founded their own independent state in the 7th century, the principality of Carantania. The oldest Slavic state, ruled from Karnburg near present-day Klagenfurt, did not last long, and came under the overlordship of the Franks.
The Slavs were originally pagan. In the 9th century, when present-day Slovenia became part of the Bavarian state and hence the Frankish empire, the population began converting to Christianity. The feudal system had begun to strengthen by the 10th century. The Freising Manuscripts, the first documented writing in Slovene in the Latin alphabet, were written at the end of the 10th century.