In its current form, the castle was likely begun by the noble house of Wagen as a replacement for Boltežar Wagen's nearby Lihtenberk Castle, already in disrepair and severely damaged by a major earthquake in 1511. After the 1630 death of Jurij Wagen, the last member of the family, the castle changed several owners until it was in 1672 finally bought by Johann Weikhard von Valvasor after his return from abroad. Thoroughly renovated, it was furnished with a graphic studio, a library, printing press and collection of curiosities. Due to the enormous cost of issuing Valvasor's book, "The Glory of the Duchy of Carniola", Valvasor became heavily indebted, and was forced to sell first his valuable library and, in 1692, his estates. His family moved to Krško, while the castle again changed several owners, the last being the noble family Windischgrätz, who abandoned the castle in 1943. While its interior furnishings were destroyed or looted, the castle itself survived the war intact and was in its immediate aftermath turned into a military hospital. From 1957 it was occupied by Jesuits, who carried out some preventive maintenance on the structure; in 1972, a systematic reconstruction effort began, at first led by the art historian Milan Železnik.