The Carpathian Basin, in which Hungary lies, has been populated by successive peoples for thousands of years. One such tribe was the nomadic Magyars, who reached the area as early as the mid-9th century. Known for their equestrian skills, the Magyars raided far and wide, until they were stopped by the Germans in 955. The defeat left the Magyar tribes in disarray, and later forced them into an alliance with the Holy Roman Empire. In the year 1000, the Magyar prince Stephen was crowned 'Christian King' Stephen I, with a crown sent from Rome by the pope, and Hungary, the kingdom and the nation, was born.
Stephen ruthlessly set about consolidating royal authority by expropriating land, establishing a system of counties, and evangelising the countryside. By the time of his death in 1038, Hungary was a nascent Christian culture, increasingly westward-looking and multi-ethnic.
The next two and a half centuries - during the reign of the House of Árpád - tested the new kingdom to the limit. The period was marked by constant struggles between rival claimants to the throne, and land grabs by powerful neighbours. Hungary's descent into anarchy was arrested only after Andrew III, the Árpád dynsasty's last in line, died in 1301.
After the death of Andrew III, Hungary flourished. A succession of able rulers, beginning with Charles Robert and culminating in the golden reign of Matthias Corvinus, made the country one of Europe's leading powers. However, the death of Matthias in 1490 resulted in another setback. His successor Vladislav was unable to maintain royal authority, funds were squandered, and retrograde laws reduced the peasantry to serfdom.
In 1526, Hungary's motley army was crushed by the Ottoman Turks at the Battle of Mohács. The defeat marked the end of a relatively prosperous and independent Hungary, and sent the nation into a tailspin of partition, foreign domination and despair. Turkish occupation did little to improve the country, and increasing resistance to their rule forced the Turks out in 1699.
The expulsion hardly created a free and independent Hungary. Instead, the country became part of the Austrian Habsburg Empire. Thus began a period of enlightened absolutism. Hungary blossomed economically and culturally under the Habsburgs, but nationalist urges were never far from the surface.
In 1849, under the rebel leadership of Lajos Kossuth, Hungary declared the dethronement of the Habsburgs and full independence. The Habsburgs replied by quickly crushing the revolution and instigating a series of brutal reprisals. Hungary was again merged into the empire as a conquered province, and absolutism was reinstated. However, passive resistance among Hungarians and a couple of disastrous military defeats for the Habsburgs prompted negotiations between the two sides. The outcome was the Compromise of 1867, which created the Dual Monarchy of Austria the empire and Hungary the kingdom. This 'Age of Dualism' set off an economic, cultural and intellectual rebirth in Hungary, but there were worrying signs that all was not well in the kingdom.
The Dual Monarchy entered WWI as an ally of Germany - with disastrous results - and was replaced by a republic immediately after the war. Hungarian Communists then seized power, but were overthrown five months later by troops from Romania. In 1920, the Allies drew up a postwar settlement under the Treaty of Trianon which drastically reduced Hungary's size. Hungary sought help from the fascist governments of Germany and Italy to get its land back, but found itself again on the losing side in WWII.
In 1947, rigged elections brought the Communists to power. Bitter feuding within the party started, and purges and Stalinesque show trials became the norm. The nation was further rocked by the 1956 uprising, an anti-Soviet revolution that left thousands dead. After reprisals - the worst in the country's history - and the consolidation of the regime, János Kádár began a programme of 'goulash' (consumer-oriented) Communism. His reforms worked, and by the mid-1970s, Hungary was the most developed, most liberal and the richest nation in the region. However, the continuing spectre of unemployment, a soaring inflation rate and mounting debt meant Kádár was ousted in 1988.
After accelerating the collapse of Communism by dismantling the fence along its border with Austria, the nation became the Republic of Hungary in 1989, and went on to hold free elections the following year - the first in more than four decades. Despite initial success in curbing inflation and lowering interest rates, a host of economic problems has slowed the pace of development.
In 2004, Hungary joined the European Union, after an April 2003 plebiscite in which Hungarians approved the country's entry into an enlarged EU.
In August 2004 Prime Minister Medgyessy was forced to resign when he lost the support of a coalition partner after a falling-out following a cabinet reshuffle. He was replaced by former minister for sport Ferenc Gyurcsány.
Returned to power in April 2006, the Gyurcsány government seemed to be enjoying a period of relative political calm in Hungary. His centre-left coalition was focused on reinvigorating the faltering national economy in preparation for joining the Euro zone. The political situation took a distinct turn for the worse in September when a speech delivered by the prime minister in a closed party meeting was leaked to the public. In the colourfully worded speech Gyurcsány admitted his government had 'lied morning, noon and night' in order to win the election. The public were understandably upset and widespread protests took place across the country with the centre of Budapest rocked by three nights of violence. The pervading sour mood continued as the nation commemorated the 50-year anniversary of the 1956 uprising. The divisive behavior of both sides of politics during the anniversary celebrations did little to heal the nation's wounds, both old and new. The municipal elections that followed were disastrous for the government, with a huge swing to the right and Gyurcsány narrowly winning a vote of confidence to keep his feeble grip on power.