From around 450 BC, Slovakia was settled by Celts, who built powerful oppida in Bratislava and Liptov. Silver coins with the names of Celtic kings represent the first known use of writing in Slovakia. From 6 AD, the expanding Roman Empire established and maintained a chain of outposts around the Danube. The Kingdom of Vannius, a barbarian kingdom founded by the Germanic tribe of Quadi, existed in western and central Slovakia from 20 to 50 AD.
The Slavic population settled in the territory of Slovakia in the 5th century. Western Slovakia was the centre of Samo's Empire in the 7th century. A proto-Slovak state, known as the Principality of Nitra, arose in the 8th century and its ruler Pribina had the first Christian church in Slovakia consecrated by 828. Together with neighboring Moravia, the principality formed the core of the Great Moravian Empire from 833. The high point of this (Proto-)Slovak empire came with the arrival of Saints Cyril and Methodius during the reign of Prince Rastislav and the territorial expansion under King Svatopluk.
After the disintegration of the Great Moravian Empire in the early 10th century, Slovakia became part of the Kingdom of Hungary in the 11th through to the 14th centuries. Due to its high level of economic and cultural development, Slovakia also retained its important position in this new state. For almost two centuries, it was ruled autonomously as the Principality of Nitra and the Nitrian Frontier Duchy. Slovak settlements extended to the northern half of present-day Hungary, while the ethnic composition of present-day Slovakia itself became more diverse due to the arrival of the Germans (from the 13th century), Vlachs (from the 14th century), and Hungarians (from the late Middle Ages).
A huge population loss resulted from the invasion of the Mongols in 1241 and the subsequent famine. However, medieval Slovakia was characterized rather by burgeoning towns, construction of numerous stone castles, and the development of art. In 1467, Matthias Corvinus founded the first university in Bratislava, but the institution was short-lived.
After the Ottoman Empire started its expansion into present-day Hungary in the early 16th century, the center of the Kingdom of Hungary (under the name of Royal Hungary) shifted towards Slovakia, and Bratislava (known as Pressburg/Pressporek/Posonium/Posony at that time) became its capital in 1536. But the Ottoman wars and frequent insurrections against the Habsburg Monarchy also inflicted a great deal of destruction, especially in rural areas. As the Turks retreated from Hungary in the 18th century, Slovakia's influence decreased.
During a revolution in 1848-49, the Slovaks supported the Austrian Emperor, with the ambition to secede from the Hungarian part of the Austrian monarchy. But they failed in the end to achieve this aim. During the period of the Austro-Hungarian Empire, from 1867 to 1918, the Slovaks experienced severe oppression in the form of Magyarisation promoted by the Hungarian government. For example, all three Slovak high schools and Matica slovenská were closed down in 1874-1875.
In 1918, Slovakia joined the regions of Bohemia and neighbouring Moravia to form Czechoslovakia. During the chaos following the breakup of Austria-Hungary, a Slovak Soviet Republic was created for a very brief period. During the Interwar period, democratic and prosperous Czechoslovakia was permanently threatened by revisionist governments of Germany and Hungary, until it was finally broken up by the Munich Agreement of 1938, when Slovakia became a separate state that would be tightly controlled by Nazi Germany. However, the anti-Nazi resistance movement launched a fierce armed insurrection, known as the Slovak National Uprising, in 1944. After World War II, Czechoslovakia was reassembled and came under the influence of the Soviet Union and its Warsaw Pact from 1945 onward. In 1969, the state became a federation of the Czech Socialist Republic and Slovak Socialist Republic.
The end of communist rule in Czechoslovakia in 1989, during the peaceful Velvet Revolution, was followed once again by the country's dissolution, this time into two successor states. Slovakia and the Czech Republic went their separate ways after January 1, 1993, an event sometimes called the Velvet Divorce, but Slovakia has remained close partners with the Czech Republic, as well as with other Central European countries within the Visegrad Group. Slovakia became a member of the European Union in May 2004.