Under the building of Buda Castle there is a multi-level cave and cellar system. Medieval and modern documents prove that one of the most important economic activities of the citizens of Buda was viniculture and the sale of wine. In the huge cellars of the buildings based on rocks wine barrels and food requiring cooling were stored. In addition to this the cellars provided excellent shelter for people during sieges and fires.
The cellar system under the buildings was usually divided into two, sometimes three parts. The upper cellar was always built first, its sidewalls were made of limestone, and in the 13th century the vault was supported by consoles, while in the 14-15th century they had barrel vaults. From the streets wide wooden doors and barrel rollers led to the depths. The middle level was half-built, half natural with limestone sidewalls, and stone or brick vaults, while the lower level was usually a hole. The cellar levels expanded under the streets in most cases. In each cellar there are fresh-water wells, which collect the waters of the limestone rock system.
During the 18-19th century - due to the demise of viniculture near Castle Hill - the cellars lost their importance. The deep cellars on the lowest level became storehouses for rubble and waste, the overflowing wells and dripping waters hollowed out the bases of the buildings. Statically the rock cellars started to endanger the houses, and spreading under the streets and squares they caused constant sinking and collapse. So from 1882 to 1886 the Engineering Office of the capital made a survey of the 120 rock cellars between Bécsi Gates Square and Dísz Square.
In February and March 1897 in Holy Trinity Square, in front of Matthias Church the road broke in. In the 27 November, 1904 issue of Budai Hírlap people could read about the dangerous conditions of the rock cellars under the buildings of the Castle, the broken floor of No. 11 Tárnok Street, the waving pond under the building of 5 Országház Street, and the overflown well of No. 6 Dísz Square. The deep cellars of the Castle were in constant danger and saving works started only between 1932 and 1936. Led by Ottokár Kadic the Hungarian Caving Society had some important archaeological and geological results by excavating the cave cellars. On 17 August 1935 the first Cave Museum was opened under the building of No. 2 Szentháromság Street. The museum displayed the hollows found under Szentháromság Square, and the medieval entrances leading to the upper cellars. In 1936 two further rooms were added to the cave system. From the human and animal bones, which were found during the excavation and clearing under today's 9 Szentháromság Street, the most horrific part of the Castle Cave, the Bone chamber, was formed.
World War II prevented the construction of the whole cave system. In May 1943 the City Council closed down the Cave Museum, the cave was taken over for military purposes, then they connected the territory under Szentháromság Square with the deep cellars excavated under Úri Street, Dísz Square and Országház Street. The 4 km-long Great Labyrinth was formed. During the air defense reconstructions a cave hospital was built in the section between Szentháromság Street and Lovas Road. In 1945, during the siege of the Castle thousands of soldiers and civilians found shelter in the hollows and rooms of deep cellars.
In the 1950s - during the years of Cold War - the whole labyrinth was transformed into a modern air-raid shelter. The sewage system was rebuilt and modernized, bathrooms and toilets were formed. Between 1961 and 1975 the Great Labyrinth was opened to the public again. The Cave Exhibition and the Castle Cave were also modernized and opened. In 1975 the deep cellar system was closed because of financial difficulties. The southern part of the cave system has been open to the public since 1983 (as the Buda Labyrinth), and the middle part, which was reconstructed in 1997, can be visited only in groups with a guide.