The first invasion of the Kingdom of Hungary by the Mongol Empire started in March 1241. The Mongols started to withdraw in late March 1242.
Background
Mongol invasion of Europe
The Hungarians had first learned about the Mongol threat in 1229, when King Andrew II granted asylum to some fleeing Rus' boyars. Some Magyars (Hungarians), left behind during the main migration to the Pannonian basin, still lived on the banks of the upper Volga (it is believed by some that the descendants of this group are the modern-day Bashkirs, although these people now speak a Turkic language, not Magyar). In 1237 a Dominican friar, Julianus, set off on an expedition to lead them back, and was sent back to King Béla with a letter from Batu Khan, Mongol ruler and founder of the Golden Horde. In this letter, Batu called upon the Hungarian king to surrender his kingdom unconditionally to the "Tatar" forces or face complete destruction. Béla did not reply, and two more messages were later delivered to Hungary. The first, in 1239, was sent by the defeated Cuman tribes, who asked for and received asylum in Hungary. The second was sent in February 1241 from Poland which was facing an invasion from another Mongol force.
Hungary's failed defence strategy
The military doctrine of the Hungarian kings prohibited nobles from constructing private stone castles/fortresses for their own protection within the realm during most of the high medieval era. Consequently, the building of stone castles was an exclusive royal monopoly in the Kingdom of Hungary. It was believed that privately built strongholds by landowners could ultimately lead to the strengthening of oligarchy and a decline in the royal power. Castles were only authorized to be built in strategically significant locations deemed important by the monarchs, primarily along the western border near the Holy Roman Empire. This policy proved to be successful to preserve the nearly absolute royal power in the realm, however it backfired during the Mongol attacks.
Cuman refugees
Following their defeat in 1239 soon after the Mongol invasion of Rus', many Cuman-Kipchak peoples were driven from their steppes further west or south. One such tribe was that of Khan Köten. According to Rogerius, Köten led a group consisting of 40,000 familias (a Latin phrase with multiple meanings) into Hungary. Some historians interpret this as Köten's tribe consisting of 40,000 families, though as pointed out by Hungarian historian András Pálóczi-Horváth the land the Cumans were expected to settle on could only support 17,000 families, suggesting Köten led 40,000 people in total. Köten sought asylum in the nearby kingdom of Hungary; the king responded that they could do so as long as the Cumans would convert to Catholicism and acknowledge him as their overlord, providing military service.
Köten agreed to Béla's conditions, promising to convert to Christianity and fight the Mongols (referred to as "Tatars" by the Hungarians). The king promptly gave them leave to settle in the plains along the Tisza River. However the Cumans, used to a nomadic and raid-based lifestyle, did not get on well with the sedentary population of Hungary. Many cases of robbery and rape were reported with Cumans as the perpetrators; Béla often refused to punish these transgressions, as he was reluctant to start a conflict with the Cumans, especially when he was already expecting a Mongol invasion. Townspeople also accused the Cumans of being agents of the Mongols.
Invasion
Five separate Mongol armies invaded Hungary in 1241. The main army under Batu and Subutai crossed through the Verecke Pass. The army of Kadan and Büri crossed through the Borgói Pass. Two smaller forces under Böchek and the noyan Bogutai respectively entered Hungary from the southeast. The army that had invaded Poland under Orda and Baidar invaded Hungary from the northwest.
Croatia and Dalmatia
Events surrounding the Mongol invasion of Dalmatia were described by medieval chronicler of Split - Thomas the Archdeacon - who was also a contemporary of these events. Thomas described the atrocities committed by the Tatars against the population of Hungary. Thomas claims that after king Béla IV returned from Austria, he spent some time in Zagreb, contemplating what to do next. Thomas claims that Béla evacuated his wife and daughters along with remains of St Stephen from Szekezfehervar and send them to the littoral parts of his kingdom. The king and his entourage eventually left Zagreb and came to Split. He demanded its citizens to prepare him a boat, which they couldn't do as fast as he demanded, so Béla took refuge on an island in nearby Trogir where he also placed his court. Meanwhile, the Mongols went on pursuit after the Hungarian king. Thomas claims that the Mongols did not manage to kill much of the local Slavic population as people took refuge in mountains and forests. After massacring prisoners near what is probably Srb, the Mongol armies reached Split. As the Mongols ravaged the town hinterland, citizens of Split prepared ballistic devices on their town walls.
According to Thomas, the Mongols thought that Béla resided in nearby Klis fortress, so they started attacking it, but they could not inflict much damage due to Klis' strategic position on a hilltop. They therefore dismounted from their horses and climbed the steep rocks on which the fortress was built. Defenders hurled rocks on climbing Tatars, kiling several, but the attacks became even fiercer and eventually hand-to-hand combat ensued, and the Mongols started looting the fortress. The Mongols eventually realized that the Hungarian king was not in Klis, so they aborted their attacks on the fort and went towards Trogir and Split.
Thomas claims that the Mongols reached the coast of Trogir and scouted the town for weak points. Béla meanwhile, evacuated his family on a boat he had rented and observed what would happen next. The Mongols issued several threats to Trogir citizens "in a Slavic language", demanding them to hand over the king. The guards gave them no response, as ordered by king Béla.
Thomas claims that the Tatars then simply withdrew and spent the entire month of March in their camps in Croatia and Dalmatia. On five or six occasions they came back to these towns, only to return to their camps. The Mongol armies eventually withdrew completely. Béla sent scouts who confirmed that the Mongol armies withdrew completely, so he immediately returned to Hungary proper. Béla's queen and his family remained in Klis fortress until September 1249. Thomas claims that two of Béla's daughters died there and were put to rest in Cathedral of Saint Domnius in Split. In the immediate aftermath of the Mongol withdrawal there was also a famine which came as a consequence of the invasion.
Mongol withdrawal
During the summer and autumn of 1241, most of the Mongol forces were resting on the Hungarian Plain. In late March 1242, they began to withdraw. The most common reason given for this withdrawal is the Great Khan Ögedei's death on 11 December 1241, which supposedly forced the Mongols to retreat to Mongolia so that the princes of the blood could be present for the election of a new great khan. This is attested to by one primary source: the chronicle of Giovanni da Pian del Carpine, who after visiting the Mongol court, stated that the Mongols withdrew for this reason; he further stated that God had caused the Great Khan's death to protect Latin Christendom.
However, Rashid Al-Din, a high minister and historian of the Mongol Ilkhanate, specifically states that Batu did not know about Ogedei's death when he decided to withdraw. He states that they withdrew from Hungary to put down a Cuman rebellion, and then left Europe later in 1242 because they felt they had completed their mission, not because of the influence of any outside force. Rashid had access to the official Mongol history when writing the Ilkhanate's history (Altan Debter); additionally as historian John Andrew Boyle points out, the section where Rashid addresses the Mongol withdrawal from central Europe contains orthography that indicates he took this version of the events directly from earlier Mongol records. By Carpini's account, a messenger would have to be able to make the journey from Mongolia to Central Europe in a little over 3 months in the middle of winter. Carpini himself accompanied a Mongol party in a much shorter journey (from Kiev to Mongolia) during the summer and fall of 1246, where the party "made great speed" in order to reach the election ceremony in time, and made use of several horses per person while riding nearly all day and night. It took five months. The History of Yuan does not mention any particular reason for the withdrawal, but does note that Batu did not seek to attend a kurultai at all, and was only convinced to attend by Subutai in the year 1244, long after he had left Hungary.
The true reasons for the Mongol withdrawal are not fully known, but numerous plausible explanations exist. The Mongol invasion had bogged down into a series of costly and frustrating sieges, where they gained little loot and ran into stiff resistance. They had lost a large number of men despite their victories (see above). Finally, they were stretched thin in the European theater, and were experiencing a rebellion by the Cumans in what is now southern Russia, and the Caucasus (Batu returned to put it down, and spent roughly a year doing so). Another theory relates to Europe's weather: Hungary has a high water table and floods easily. An analysis of tree rings by modern researchers has found that Hungary had a cold wet winter in early 1242 (contributing to the famine), which likely turned Hungary's central plain into a huge swamp. Lacking pastures for their horses, the Mongols would have had to fall back to Russia in search of better grasslands.
Regardless of their reasons, the Mongols had completely withdrawn from Central Europe by mid-1242, though they still launched military operations in the west at this time, most notably the 1241–1243 Mongol invasion of Anatolia. After the withdrawal of the Mongol troops, Subutai was reassigned by Güyük Khan to engage the Southern Song, and died of old age in 1248.
Aftermath
Devastation of Hungary
Master Roger on the Destruction of Várad by the Mongols
[The Mongols] burnt the church [in Várad], together with the women and whatever there was in the church. In other churches they perpetrated such crimes to the women that it is better to keep silent ... Then they ruthlessly beheaded the nobles, citizens, soldiers and canons on a field outside the city. ... After they had destroyed everything, and an intolerable stench arose from the corpses, they left the place empty. People hiding in the nearby forests came back to find some food. And while they were searching among the stones and the corpses, the [Mongols] suddenly returned and of those living whom they found there, none was left alive.
The effects of the Mongol invasion were tremendous in the Kingdom of Hungary. The worst damage was incurred in the plains regions, where 50-80% of settlements were destroyed. The combination of massacres perpetrated by the Mongols, the famines induced by their foraging, and the simultaneous devastation of the countryside by the fleeing Cumans resulted in an estimated loss of 15–25% of Hungary's population, some 300,000–500,000 people in total. The only places that held in the face of Mongol assaults were approximately eighty fortified places, including all of the few stone castles in the kingdom. Among these places were Esztergom, Székesfehérvár, and the Pannonhalma Archabbey. However, these places were relatively few; a German chronicler in 1241 noted that Hungary "had almost no city protected by strong walls or fortresses", so the majority of settled areas were extremely vulnerable.