Burghausen Castle The Burghausen Castle in Burghausen , Upper Bavaria is the longest castle complex in Europe ( 1 , 043 m ) . History . The castle hill was already settled in the Bronze Age . The castle ( which was founded before 1025 ) was transferred to the Wittelsbach s after the death of the last count of Burghausen Gebhard II in 1168 . In 1180 they were appointed duke of Bavaria and the castle was extended under duke Otto I of Wittelsbach . With the first partition of Bavaria in 1255 Burghausen Castle became the second residence of the dukes of Lower Bavaria , the main residence was Landshut . In 1255 under Duke Henry XIII ( 1253 – 1290 ) the work for the main castle commenced . In 1331 Burghausen and its castle passed to Otto IV , Duke of Lower Bavaria . Under the dukes of Bavaria - Landshut ( 1392 - 1503 ) , the fortifications were extended around the complete castle hill . Starting with Margarete of Austria , the deported wife of the despotic Duke Henry XVI ( 1393 – 1450 ) , the castle became the residence of the Duke ' s consorts and widows , and also a stronghold for the ducal treasures . In 1447 Louis VII , Duke of Bavaria died in the castle as Henry ' s prisoner . Under Duke Georg of Bavaria ( 1479 – 1503 ) the work was completed and Burghausen Castle became the strongest fortress of the region . Also after the reunification of Bavaria in 1505 with the Landshut War of Succession the castle had military importance , also due to the threat of the Ottoman Empire it was subsequently modernised . During the Thirty years war Gustav Horn was kept imprisoned in the castle 1634 - 1641 . After the Treaty of Teschen in 1779 Burghausen Castle became a border castle . During the Napoleonic Wars the castle suffered some destruction . Architecture . The gothic castle comprises the main castle with the inner courtyard and five outer courtyards . The outermost point of the main castle is the " Palas " with the ducal private rooms . It today houses the Castle museum , including late Gothic paintings of the Bavarian State Picture Collection . On the town side of the main castle next to the donjon is the gothic , inner " Chapel St . Elizabeth " ( 1255 ) and the " Dürnitz " ( knights ' hall ) with its two vaulted halls . Opposite to the " Dürnitz " are the wings of the Duchess . The first outer courtyard was protecting the main castle and included also the stables , the brewery and the bakery . The second courtyard houses the large " Arsenal building " ( 1420 ) and the gunsmith ' s tower . This yard is protected by the dominant " Saint George ' s Gate " ( 1494 ) . The Grain Tower and the Grain Measure ' s Tower was used for stabling and as a store for animal food , they belong the third courtyard . The main sight of the forth courtyard is the late Gothic , outer " Chapel St . Hedwig " ( 1479 – 1489 ) . The court ' s officials and craftsmen worked and lived in the fifth courtyard which was once protected by a strong fortification . In 1800 this fortification was destroyed by the French under Michel Ney . The " Pulverturm " ( " Powder Tower " , constructed before 1533 ) protected the castle in the western valley next to lake Wöhrsee . A battlement connects this tower with the main castle .