The castle was built for the order of king Béla IV, after the invasion of the Mongols in 1241-42, by the Tomaj family. It was first mentioned in 1282, when it became the property of the king. In the next centuries the ownership of the castle changed several times, eg. it was owned by king László IV, Aba Amádé, Károly Róbert, the Drugeth family, king Zsigmond, Czudar Péter, Brankovics György, king Matthias, Szapolyai János, Báthori István, Martinuzzi Fráter György, the Bebek family, Rákóczi György I., etc. The Germans blew it up in 1702 - like nearly all other castles in the Kingdom of Hungary - after the lost war for independence led by Rákóczi Ferenc II. Its last owners were the Zichys before the nationalization in 1947.