The last count of Nidau, Rudolf IV died in 1375 in a battle in the Gugler War. The next owner of the castle was the Prince-Bishop of Basel, Johann von Venningen. However, he was defeated in 1376 and the Counts of Kyburg acquired the castle. In 1379, Count Rudolf von Kyburg sold the castle and town to the Habsburgs. The Habsburgs then gave the castle as a fief to Enguerrand de Coucy, the former commander of the Guglers, in 1387. During the Sempach War, in May 1388, Swiss Confederation forces from Bern and Solothurn attacked and besieged the town and castle for seven weeks before taking Nidau. The castle was heavily damaged and the Swiss forces suffered heavy losses in the battle. Following the war, the town and castle were awarded to Bern in the peace settlement. Portions of the city were damaged or destroyed in fires in 1388, 1413, 1513 and 1743.