Hungary's history has been one of conquest and invasion, drastically shifting borders, and widely divergent political systems. The Kingdom of Hungary was invaded by the Ottoman Empire in the 16th century. Hungary was later incorporated into the Austrian Hapsburg monarchy, which in 1867 ceded much autonomy to Hungary in a dual Austro-Hungarian empire. After World War I, the Austro-Hungarian monarchy collapsed, and many successor states emerged. Hungary lost about two-thirds of its former territory as a result of the 1920 Trianon peace treaty. In World War II, Hungary allied with Nazi Germany and during this time regained much of its former territory at the expense of Czechoslovakia and Romania, but the Trianon borders were essentially restored after the war. With support from the Soviet Union, the Hungarian Communist Party imposed a one-party system, and the People's Republic of Hungary was declared in 1949. A popular uprising against Communist rule in 1956 was crushed by invading Warsaw Pact forces. Communist leader Janos Kadar, who ruled from 1956 to 1989, embarked on cautious liberalization and economic reform policies during his tenure.
In 1989, the year of East European revolutions, Hungary gradually but systematically moved toward a multiparty democracy. A peaceful transition from communism to democracy was confirmed in the first freely contested elections in 1990. The conservative Hungarian Democratic Forum (MDF) won 43% of the vote and led a noncommunist coalition government with Jozef Antall as prime minister. Unlike the other new democracies, Hungary faced no early elections or toppled governments for four years and appeared to many observers to be an island of stability in the region. The process of economic transformation, however, incurred considerable costs, leading to recession, rising unemployment, and declining output. New elections in 1994 returned the former Communist Party to power. The Hungarian Socialist Party won a majority of seats in Parliament. Though able to govern alone, the Socialists worked out a coalition agreement with the liberal Alliance of Free Democrats. Gyula Horn of the Socialist Party became prime minister. Strains in the coalition became evident in late 1994 and early 1995, due to differences over economic policy and privatization. After months of delay, in March 1995, the Horn government launched sweeping economic reforms designed to stabilize the economy and reduce the country's foreign debt and budget deficit. The austerity measures were hugely unpopular, but contributed to a significant economic turnaround. Growth in gross domestic product (GDP) in Hungary reached 4.7% in 1997 and 5.5% in 2000.
Leading up to the elections in May 1998, the Hungarian Socialist Party and the opposition Federation of Young Democrats-Hungarian Civic Party (Fidesz) led in opinion polls. The Fidesz-Hungarian Civic Party ended up with the largest share of parliamentary seats, but short of a majority. Fidesz concluded negotiations on forming a ruling coalition with the Hungarian Democratic Forum and the Independent Smallholders Party; altogether the coalition commanded 213 of 386 seats in Parliament. Fidesz leader Viktor Orbán became prime minister of a center-right government. In the April 2002 elections, the Socialist Party challenged Orbán's Fidesz, and although Fidesz won the largest bloc of seats in the National Assembly in the second round (aligned with the Hungarian Democratic Forum), the Socialists formed a coalition government with the Alliance of Free Democrats, holding 198 of 386 seats. Péter Medgyessy was named prime minister.