As a result of the development of military technology Buda castle did not play an important role as a military fortress in the 20th century. Nevertheless its location and natural features of a fortress, and the closeness of the best crossing places of the Danube made it the main scene of action during World War II.
On the 3rd of April 1944 the British-American, then the Soviet air force started to bomb Hungary and Budapest, designating it as the centre of Hungary's military industry. The castle was spared from the 25 bombing raids carried out up to the end of October, since the main targets were the industrial districts and traffic junctions (primarily railway stations).
As a result of the air raids the capital started to build air raid shelters. The castle - due to its natural features, and the system of caves and cellars underneath it - was suitable for this purpose. The shelter for 2000 people, which opened from Lovas road, was finished by July. It could also be reached from Szentháromság utca through the Big Labyrinth (Nagy labirintus). During the summer air raids some 10,000 people would spend the night in the Tunnel, which was considered a public shelter.
Although the Hungarians constantly called for Budapest to be declared an "open city" Hitler stubbornly wanted to defend the city - even if it meant its destruction - to the last, in order to hold back the Soviet troops advancing on Vienna for as long as possible. In fact the German commander had the Hungarian army, which was comparable to the German force, ensconced in the town. Both the German and the Hungarian High Command worked under the Várhegy in a bunker that could be reached from the centre of the Tunnel.
The blockade of the Soviet troops closed around the capital at Christmas 1944. Attacks were launched from the second Ukrainian front from the east, and from the third Ukrainian front from the west. In the following weeks heavy street fighting, which resulted in major losses both in lives and material, closed the ring. By the 18th of January the German and Hungarian troops had been completely driven out of Pest. While retreating they blew up the two remaining bridges across the Danube: the Elisabeth Bridge and the Chain Bridge.
The siege of the inner part of Buda was started by the Soviet troops at the end of January after they had repulsed the third and last German relief attempt. At that time the Soviet bombers attacked the castle, which had almost no air defence, for the whole day. There was heavy bombing on the 30th of January, when the Várkert (Castle Garden) was destroyed beyond recognition.
On the 11th of February only the Várhegy (Castle Hill) and Naphegy (Sun Hill) behind it remained in the hands of the defenders. The exhausted army of 40,000 defenders, which had no lines of supply and had run out of food and ammunition, tried to break out of its hopeless position through the Bécsi kapu and Vármezo that evening. The majority of them died in the horrific fire of the artillery and infantry on the slopes of Várhegy. Some of them reached the forests near Buda, but the majority of them were captured or killed by the pursuers. Out of the 40,000 (half were Hungarian and half were German) soldiers only some 600 to 700 managed to reach their own lines. About 20,000 of them died in this attempt, and as many were taken prisoner.
After the failure of the attempt to break out the Soviet troops quashed all resistance in the castle by the 13th of February. The Buda Volunteer Regiment - who changed sides - also took part in this fighting. As a sign for the Soviet command to acknowledge them, they hoisted the Hungarian flag on the castle next to the Soviet one. The liberation of Budapest ended with the occupation of the castle after a 48-day siege.
The destruction wrought by the siege was the worst the castle quarter had ever seen. Out of some 200 houses only one survived the fighting intact. One fifth of the buildings were totally destroyed, and the others suffered various degrees of damage. The heaviest damage was to the Palace. The whole building was burnt out, its dome had collapsed, its roofs and staircases had come down, and the walls of the southern wing had also collapsed.