Slavic tribes wandered west into what would become Slovakia some time around the 5th century; in the 9th century, the territory was part of the short-lived Great Moravian empire. It was about this time that the Magyars (Hungarians) set up shop next door and subsequently laid claim to the whole territory. When in the early 16th century the Turks moved into Budapest, Hungarian monarchs took up residence in Bratislava (known then as Pozsony in Hungarian). Being Hungarian frontierland, many fortresses were constructed here during the Middle Ages and can still be seen today.

It wasn't until the 19th century that Slovakia, thanks to national hero Ľudovít Štúr, successfully forged its own literary language. In the early 1900s Slovak intellectuals cultivated the ties with neighbouring Czechs that would take their nation into the united Czechoslovakia post-WWI. The day before Hitler's troops invaded Czechoslovakia in March 1939, Slovak leaders declared Slovakia a German protectorate and a brief period of sovereignty ensued. This was not a popular move and in August 1944 Slovak partisans instigated the ill-fated Slovak National Uprising (Slovenské národné povstanie; SNP), a source of ongoing national pride (and incalculable street names).

After the reunification and communist takeover in 1948, power was centralised in Prague until 1989 when the Velvet Revolution brought down the Iron Curtain here. Elections in 1992 saw the left-leaning nationalist Movement for a Democratic Slovakia (HZDS) come to power. Scarcely a year later, without referendum, the Czechoslovak federation dissolved peacefully (albeit with far from universal support among Slovaks) on 1 January 1993, bringing Slovakia its first true independence.

Slovakia was accepted into NATO and the EU by 2004, became a Schengen member state in 2007, and adopted the euro as the national currency in January 2009. Respective renaissances as a major stag-party and ski-break destination in the early 2000s were catalysts for getting wider attention from international tourism.

Robert Fico of the social-democratic Smer-SD party became prime minister in 2012 (his second period in power). In March 2018, Fico resigned in the wake of the mass protests that followed the murder of investigative journalist Ján Kuciak and his fiancée Martina Kušnírová. Peter Pellegrini, formerly the deputy prime minister, was swiftly sworn in to replace Fico.