Slovenes can make a credible claim to have invented democracy. By the early 7th century their Slavic forebears had founded the Duchy of Carantania (Karantanija), based at Krn Castle (now Karnburg in Austria). Ruling dukes were elected by ennobled commoners and invested before ordinary citizens. This model was noted by the 16th-century French political theorist Jean Bodin, whose work was a key reference for Thomas Jefferson when he wrote the American Declaration of Independence in 1775-76. Carantania (later Carinthia) was fought over by Franks and Magyars from the 8th to 10th centuries, and later divided up among Austro-Germanic nobles and bishops. By 1335 Carantania and most of present-day Slovenia, with the exception of the Venetian-controlled coastal towns, were dominated by the Habsburgs.
Indeed, Austria ruled what is now Slovenia until 1918, apart from a brief interlude between 1809 and 1813 when Napoleon created six 'Illyrian Provinces' from Slovenian and Croatian regions and made Ljubljana the capital. Napoleon proved a popular conqueror as his relatively liberal regime de-Germanised the education system. Slovene was taught in schools for the first time, leading to a blossoming of national consciousness. In tribute, Ljubljana still has a French Revolution Sq (Trg Francoske Revolucije) with a column bearing a likeness of the French emperor.
Fighting during WWI was particularly savage along the Soča Valley - what would later become known as the Isonzo Front, which was occupied by Italy then dramatically retaken by German-led Austrian-Hungarian forces. The war ended with the collapse of Austria-Hungary, which handed western Slovenia to Italy as part of postwar reparations. Northern Carinthia, including the towns of Beljak and Celovec (now Villach and Klagenfurt), voted to stay with Austria in a 1920 plebiscite. What remained of Slovenia joined fellow south (jug) Slavs in forming the Kingdom of Serbs, Croats and Slovenes, later Yugoslavia.
Nazi occupation in WWII was for the most part resisted by Slovenian partisans, though after Italy capitulated in 1943 the anti-partisan Slovenian Domobranci (Home Guards) were active in the west and, in a bid to prevent the communists from taking political control in liberated areas, threw their support behind the Germans. The war ended with Slovenia regaining Italian-held areas from Piran to Bovec, but losing Trst (Trieste) and part of divided Gorica (Gorizia).
Slovenia, with only 8% of the national population, was the economic powerhouse of Tito's Yugoslavia, producing up to 20% of the national GDP. By the 1980s the federation was becoming increasingly Serb-dominated, and Slovenes, who already felt taken for granted economically, feared losing their political autonomy. After free elections, Slovenia broke away from Yugoslavia on 25 June 1991. A 10-day war that left 66 people dead followed; rump Yugoslavia swiftly signed a truce in order to concentrate on regaining control of coastal Croatia. Slovenia was admitted to the UN in May 1992 and, together with nine other 'accession' countries, became a member of the EU in May 2004. In January 2007 Slovenia replaced the tolar with the euro as the national currency.
Slovenia shared the presidency of the EU Council with France in 2008, the same year that saw the death of President Janez Drnovšek of cancer at age 57. In the national elections of October of that year, Janez Janša's coalition government was defeated by the Social Democrats under Borut Pahor, who was able to form a coalition with three minority parties.