The first decade of the 14th century sees the demise of two long-established indigenous dynasties in eastern Europe. The Magyar line of the Arpads flickers out in Hungary, after more than three centuries, with the death of Andrew III. Slav rule by the Premyslid family in Bohemia is brought to a more abrupt end by the bedroom assassination of Wenceslas III in 1306.

In each case the event ends the ethnic link between the ruling dynasty and the people. Both kingdoms now take their place in the patchwork quilt of medieval European dynasties. Hungarian and Czech nobles insist upon the right to choose their kings. And tempting alliances are on offer.

The Hungarian crown is competed for in 1301 by three candidates - from Bohemia, Bavaria and the Naples branch of the house of Anjou. More than any other great family at this time the Angevins are collectors of European kingdoms, principalities and dukedoms (in England and much of France, in Sicily and Naples). In their dynastic career they have usually had papal support, and once again young Charles Robert of Anjou-Naples (13-years-old in 1301) is the pope's choice.

The struggle for the Hungarian crown lasts eight years, but the Angevin prince - now old enough to rule on his own account - is finally enthroned at Buda in 1309 as Charles I of Hungary.

Charles and his son, Louis I, rule for more than seventy years, providing Hungary with a period of prosperity and expansion. Moldavia and Walachia are brought briefly under Hungarian control. Bosnia and Serbia are enrolled as vassal states.

Hungary is at this time closely linked with Poland. Louis' mother is a sister of Casimir III, king of Poland. In 1370 Louis inherits the Polish crown from his uncle Casimir, who is childless. And Louis is succeeded on the Polish throne by his daughter Jadwiga. Between this period and the disaster of Mohacs, in 1526, such links are common between the three eastern European kingdoms.

Between 1342 and 1526 five Hungarian monarchs also rule another of the eastern European kingdoms. They are Louis I (Hungary from 1342, Poland from 1370); Sigismund (Hungary from 1385, Bohemia from 1419): Wladyslaw III (Poland from 1434, Hungary from 1440): Vladislav (Bohemia from 1471, Hungary from 1490); and Louis II (Hungary and Bohemia from 1516).

These links, variously the result of marriage, election or war, are typical also of the dynastic politics of western Europe at this time. But the rulers of these three kingdoms confront one problem which is unique to them - a growing threat to their eastern borders from the Turks. It is met largely by the efforts of the Hungarians.

Janos Hunyadi: 1440-1456

Early in the 1440s the fortress of Belgrade is placed under the command of Janos Hunyadi, a Hungarian warrior who has proved his worth in frequent encounters with the Turks in these frontier regions. Belgrade, previously the Serbian capital, has been in Hungarian hands since 1427. But the kingdom of Serbia is now a vassal state of the Turks. Indeed the Ottoman sultan, Murad II, has a Serbian princess as a wife.

From Belgrade Hunyadi marches east in 1443 against Murad, leading a Christian army down the Danube in what is effectively a crusade. At first the crusaders have a great measure of success.

In November 1443 Hunyadi takes Nis and Sofia. Within the next three months he liberates Serbia, Bulgaria and Albania from their Muslim overlords. In June 1444 the Turks accept their loss of these territories and agree to a ten-year truce.

This considerable achievement is immediately undone by Christian zeal and duplicity. A cardinal absolves Hunyadi and the other leaders from their truce with the sultan, encouraging them to renew the crusade and to press further east. This time they are less successful.

In November 1444 the Hungarians and their allies are confronted by Murad, who has an army perhaps four times the size of theirs, at Varna on the coast of the Black Sea. The crusaders are utterly routed. Wladyslaw III, the young king of both Hungary and Poland, dies on the battlefield.

This victory begins a decade of successes for the Turks, culminating in the capture of Constantinople by Murad's son, Mehmed II, in 1453. By 1456 the Turks are once more threatening Belgrade. Seventeen years after his first appointment to defend the city, Hunyadi is again in charge but with greater responsibilities. Since 1446 he has been regent of Hungary, during the reign of the boy king Laszlo V.

Belgrade: 1456

The conclusion of the mid-15th century saga between the Hungarians and the Turks is more in keeping with the spirit of a crusade than anything that has gone before. Turkish pressure westwards along the Danube brings an army in 1456 to the walls of Belgrade.

Leaving his eldest son Laszlo with the garrison, Hunyadi departs to raise a force to relieve the city. He is helped in this task by the preaching of a Franciscan friar, St John of Capistrano. John's persuasive voice inspires a large number of peasants to join Hunyadi's small professional army in an assault on the infidel.

In July 1456 this motley army drives the Turks from the walls of Belgrade, routing them so convincingly that the sultan, Mehmed II, withdraws to his new capital at Istanbul. Bulgaria and Serbia remain under Turkish rule, and Albania succumbs again in 1478. But the victory provides Hungary with a respite of seventy years before the Turks renew their pressure.

Within weeks of this success both Hunyadi and his inspirational preacher die in camp of the plague. But Hunyadi's stature as a national hero is now such that two years later the Hungarian nobles elect his son, Matyas, as king of Hungary. He becomes Matthias I, also known as Matthias Corvinus.

Matthias Corvinus and his successors: 1458-1526

Matthias is elected king of Hungary in 1458 after the sudden death, perhaps from poison, of the 17-year-old Laszlo V. Matthias is only one year older than Laszlo. The choice falls upon him purely as the oldest surviving son of his heroic father, Janos Hunyadi (Matthias' elder brother, Laszlo Hunyadi, has recently been murdered). But in a long reign of thirty-two years Matthias demonstrates beyond dispute his own fitness for the job.

He develops a fair and efficient administration, unpopular only with the leading nobles whose power is restricted. He forms a professional standing army, the so-called Black army, enabling him to extend greatly the frontiers of his realm.

Moravia and Silesia are brought under Hungarian control, as is most of Austria. But this enlarged realm is the last kingdom of Hungary to be ruled by a native Hungarian (indeed it is the only such kingdom since the end of the Arpad dynasty). It does not survive the death of Matthias in 1490.

The conquered territories immediately break away. The nobles resume their privileges, undo the reforms of Matthias, and elect the weak Bohemian king Vladislav - largely because through him they can control Hungary again. Vladislav is succeeded in 1516 by his 10-year-old son, Louis II. Another ten years pass before Louis leads a Hungarian force against the Turks at Mohacs.

Battle of Mohacs: 1526

The weakness of Hungary and Bohemia, under the rule of the 15-year-old Louis II, attracts the interest of an aggressive young sultan of Turkey, newly on the throne as Suleiman I. In 1521 he sends a demand for tribute. When it is rejected he marches west and captures Belgrade.

In 1526 Suleiman pushes further up the Danube. Forced now into action to defend Budapest, Louis II brings an army south to meet him. Devoted until now to a life of pleasure, the young king approaches his enemy with reckless courage but little wisdom. At the centre of 20,000 hastily gathered troops, he rides against some 100,000 Turkish janissaries, well trained and hardened in warfare.

The clash occurs at Mohacs. The Hungarians are annihilated and the king killed, probably by drowning when in flight. Suleiman briefly advances as far as Budapest and then withdraws, taking with him 100,000 Hungarians.

This disaster, devastating in itself, also has significant repercussions. The Habsburg ruler of Austria, Ferdinand I, is married to the sister of Louis II, who has died without an heir. Ferdinand now claims Louis' two thrones. After some initial opposition the Habsburg claim is accepted in Bohemia, but it provokes years of civil war in Hungary.

Hungary divided: 1526-1699

Half the Hungarian nobles accept the claim of Ferdinand I to the vacant throne; the others elect one of their own number, John Zápolya. Warfare between the two factions is interrupted by an occasional truce, such as the secret treaty of Nagyvárad in 1538 which gives Transylvania and central Hungary, including Budapest, to John Zápolya, while acknowledging Ferdinand's rights to western Hungary.

The resulting peace lasts only until John Zápolya's death two years later, when the renewal of turmoil encourages the Turks to intervene once more.

The Turkish sultan, Suleiman I, marches north in 1541 and takes Buda. During the next few years he wins the whole of Hungary except the western strip adjacent to Austria. In 1547 the sultan offers a treaty which is somewhat humiliating for Ferdinand - but by then the Austrian ruler, busy with Reformation struggles on his German flank, is glad of a respite.

By the terms of the treaty Transylvania (under John Sigismund, the young son of John Zápolya) becomes a vassal state of the Turks. Central and southern Hungary, including Buda, are absorbed within the Ottoman empire. And Ferdinand is to pay an annual tribute of 30,000 ducats to Suleiman I for the small western part of the old Hungarian kingdom.

Of these three sections of Hungary, the semi-independent principality of Transylvania fares best during the next century and a half. Southern Hungary withers as an outpost of the Ottoman empire. Western Hungary suffers, like neighbouring Bohemia, from Habsburg efforts to impose the Counter-Reformation on a population which is mainly Protestant. This region bears the added strain of still being Christendom's front line against the Turks, who might at any moment press westwards.

When the Turkish assault finally comes, with the siege of Vienna in 1683, it proves to be a turning point - but to Habsburg rather than Ottoman advantage.

Vienna and Hungary: 1683-1718

On 31 March 1683 a huge Turkish army marches west from Edirne. On the same day, in Warsaw, the Polish king John III Sobieski signs a treaty committing him to bring a force to the defence of Vienna. There is panic in the Austrian capital as the Turks approach, with a force estimated to be about 250,000 strong. Early in July the emperor and his court abandon Vienna, slipping away to safety higher up the Danube. A few days later the invading army arrives to blockade the city.

Two months pass before John III arrives with his Polish contingent, reinforced by Catholics from Bavaria and by Protestants from Saxony. The Christian army amounts to about 70,000 men.

The attack on the Turkish force takes place on September 12. After eight hours of fighting the Turks are routed and the city relieved. It is a symbolic moment which also proves a turning point, inspiring the Austrians to transform the retreat of the Turks into a lasting withdrawal.

Further campaigns to the east result in the capture of Buda in 1686, followed by the gradual recovery of other parts of Hungary. By 1699 the Turks are willing to sign the peace of Karlowitz, ceding to the Habsburg emperor, Leopold I, the whole region of Hungary which has been under Turkish control since 1547 - apart from the small area of Banat in the extreme southeast, which remains with the Turks until 1718.

Exhilarated by this gradual process of liberation from their Muslim overlord, the Hungarian diet - meeting at Pressburg in 1687 - grants more of Leopold I's demands than he might normally have expected. They give up their ancient claim to elect the king, allowing instead a hereditary Habsburg right to the crown of St Stephen.

Having recovered a kingdom which he considers his by descent from Ferdinand I, Leopold applies to Hungary the blend of absolute rule and religious intolerance which has reduced Bohemia to a state of abject decline. Hungary proves more resilient. The removal in 1703 of Austrian troops, needed elsewhere in the War of the Spanish Succession, is followed by a series of uprisings.

Calm is not fully restored until 1710. By then the Austrian emperor is in more conciliatory mood. In a series of agreements, finalized in a diet of 1723 during the reign of Charles VI, it is accepted that Hungary will not be merged with the rest of the Austrian empire. It will continue to be ruled through its own diet, according to its own laws and traditions, as a separate kingdom.

This special status survives almost unbroken until the end of the Austrian empire in 1918, but only just. From the middle of the 19th century there is mounting clamour for reform and independence.