During the
Early Middle Ages there was a small fort and church on the top of the castle hill. The castle was built between 1180 and 1190 by
Duke Berthold V of Zähringen, who constructed the still preserved
keep to the level of the Knights' Hall (). The tall Knights' Hall was built as the centerpiece of a monument to Zähringen power. However, the family never lived in the castle, preferring
Burgdorf Castle. In 1218 it was inherited by the
House of Kyburg, who built the upper levels above the Zähringen castle. A quarrel over who would rule the southern Kyburg lands led, in 1322, to Eberhard II von Kyburg murdering his brother Hartmann II at the castle. To protect his newly acquired land from the
Habsburgs Eberhard II then sold them to Bern and was promptly given them back as a
fief. The Kyburgs ruled over the region for nearly two centuries until a failed raid by Rudolf II on
Solothurn, in 1382, started the
Burgdorferkrieg (also
Kyburgerkrieg). After several decisive
Bernese victories the Kyburgs were forced to concede an unfavorable peace. In 1384 Bern bought Thun and Burgdorf, the most important cities of the Kyburg lands. The castle came under Bernese control and became the seat of their local administration. c. 1844 The massive roof (1430–36) comes from the Bernese period. Due to the lack of residences in the castle, in 1429, an administrative and residential wing was added to the west of the keep, built in late
Gothic style, and known as the "new castle". The castle was the seat of the local court and since at least the 17th century there was a prison under the roof of the
donjon. In 1886 a new prison was built on the castle grounds. Two years later, in 1888, the museum opened in the castle. For a time the jailer was also the ticket seller and guard for the museum. In 2006, the castle was bought by the city of Thun from the canton of Bern. Until the end of 2009 the Bernese Oberland regional court was based in the castle. ==The castle museum==