Originally built by the Teutonic Knights, a German Roman Catholic religious order of crusaders, in a form of an Ordensburg fortress. The Order named it Marienburg (Mary's Castle). The town which grew around it was also named Marienburg. In 1466, both castle and town became part of Royal Prussia, a province of Poland. It served as one of the several Polish royal residences, interrupted by several years of Swedish occupation, and fulfilling this function until Prussia claimed the castle as a result of the First Partition of Poland in 1772. Heavily damaged after World War II, the castle was renovated under the auspices of modern-day Poland in the second half of the 20th century and most recently in 2016. Nowadays, the castle hosts exhibitions and serves as a museum.