With the collapse of the Hapsburg monarchy in 1918, the Slovenes, with Croats and Serbs from the Austro-Hungarian empire, joined with the Serbian kingdom to form the Kingdom of Serbs, Croats, and Slovenes, later renamed Yugoslavia. During the World War II (1939–45), much of Slovenia was incorporated into the Third Reich, with the remainder split between German allies Hungary, Italy, and the Nazi puppet state in Croatia. Following the war, Slovenia became one of the six constituent republics of the Socialist Federal Republic of Yugoslavia.
From 1945 to 1980, Yugoslavia was ruled by Josip Broz, popularly known as Marshal Tito. Though a communist, one-party state, Tito steered the country on an independent course from the Soviet Union. After 1980, Yugoslavia was ruled by a collective presidency. In this Yugoslav state, Slovenia was consistently the most progressive region. The Slovene members of the federal communist party were usually in the forefront of economic and political reform. Slovenia was by far the most developed of the Yugoslav republics, with only 8% of Yugoslavia's population contributing up to 20% of its gross national product (GNP) and 30% of its foreign trade. By the early 1980s, as the Yugoslav national economy faced growing crises, the Slovenes pushed for a greater reliance on market forces and greater acceptance of political pluralism.
By the mid-1980s, Slovenia's communist party had been rebuffed on economic issues by conservatives in the Serbian party who sought to recentralize the economy and party. The Slovenes also saw Serbian repression in the Albanian-populated province of Kosovo as a major obstacle to Yugoslav membership in the European Community, which was a priority for the Slovene leadership.
Although many independent political movements arose in Slovenia in the mid-1980s, the major turning point in Slovene politics came in May 1988 when two Slovene journalists uncovered an alleged plot by the Yugoslav army to arrest 200 Slovene officials, intellectuals, and journalists and to use armed intervention to put down any protests. This event destroyed any hope in the Slovene party and society for reforming Yugoslavia through the federal government in Belgrade. From this point on, despite continued political, economic, and even military pressure from the Serbian communists, the Slovenes moved on their own. Independent political parties were formed, and in January 1989 the Slovene Communist Party admitted the need to accept a multi-party system. Slovene party chief Milan Kucan continued to defend the human rights of Albanians in Kosovo. At the federal party congress in January 1990, the Slovene delegation rejected Serbian demands for a recentralized party and called instead for the independence of republic parties, free multi-party elections, and respect for human rights. The Serbs rejected Slovenia's proposals, and the Slovenes walked out of the congress, marking the end of the Federal League of Communists of Yugoslavia.
The Slovene Communist Party renamed itself the Party of Democratic Renewal (PDR) and adopted a platform similar to the social democratic parties of Western Europe. It established a multi-party system in Slovenia, with the hope that by championing Slovenia's rights in the face of Serbian pressure, it had gained the legitimacy needed to win the upcoming elections. In the April 1990 elections, however, a coalition of six center and rightist parties, founded in 1989 under the name of the United Democratic Opposition of Slovenia (DEMOS), won 123 of 202 seats in Parliament. The head of the PDR, Milan Kucan, however, won the presidency with 58% of the vote.
In December 1990, the Slovenes overwhelmingly voted in a referendum for independence, giving the leadership six months to negotiate a new form of association with the other Yugoslav republics. In subsequent negotiations between the presidents of the Yugoslav republics, Kucan and Croatia's president, Franjo Tudjman, insisted on a new, confederal form of Yugoslavia while the Serbian and Montenegrin leaders insisted on a more centralized federation. By June
1991, the Slovene Parliament declared that Slovenia would begin the process of dissociating from Yugoslavia. Although it allowed that the Yugoslav army would remain in Slovenia for three years and explicitly recognized the legitimacy of existing Yugoslav institutions, this was taken as an illegal declaration of independence by the Slovene army. On 25 June 1991, units of the Slovene territorial defense force took control over border crossing posts on Slovenia's international borders from the Yugoslav customs service.
The federal Yugoslav army, which was allied with the Serbian Communist Party and had always opposed Slovenia's reformist moves, took this as the excuse to move into Slovenia to crush the new Slovene government and bring it back under Belgrade's control. The army, however, was met with surprisingly strong Slovene resistance. After diplomatic intervention by the European Community (EC), both sides agreed to a ceasefire. Slovenia froze its moves toward independence for three months while negotiations on the future of Yugoslavia continued. Stunned by their de facto defeat, the federal army agreed to pull out of Slovenia. The attack solidified full and unconditional support for independence within Slovenia. This support was reinforced by the full-scale attacks by the Yugoslav army on civilian targets in neighboring Croatia in the summer and fall of 1991. By December, the Slovenes had officially requested diplomatic recognition from the EC, which was granted on 15 January 1992. The United States recognized Slovenia in June 1992.
Milan Kucan served two five-year terms as president of Slovenia from 1992–2002. Janez Drnovšek was elected president on 1 December 2002; his inauguration was 23 December.