Currently classed as a National Monument, this is also the focal point of the mysticism of the "Dias Medievais de Castro Marim" (Castro Marim Medieval Days) event.
Castro Marim was occupied by various peoples until the Christian Reconquest of the Iberian Peninsula, and was considered to be of considerable strategic importance for trade with the peoples of the Mediterranean, In 1277, King D. Afonso III granted it a Carta de Foral (a royal charter used to establish a municipality), with privileges to attract new inhabitants. During the reign of King D. Dinis, the fortifications were strengthened and a new Carta de Foral was granted in 1282. Thanks to its geographical location on the border, and with help from King D. Dinis and the papal bull issued by Pope John XXII, Castro Marim Castle served as the headquarters of the Order of St. James from 1319 until 1356. By this time, the battles against the Moors had ceased and the area gradually lost prestige, causing King D. Pedro I to transfer the Order's headquarters to Tomar. From this point on, the town's population began to decline.
In the 15th century, overseas campaigns and the proximity to North Africa meant that Castro Marim became one of the main garrison towns for troops on their way to fight overseas. During the reign of King D. Manuel I, and with a new Carta de Foral having been granted in 1504, work began to restore and defend the castle as a support structure for Portugal's overseas conquests.
In 1640, during the Guerra da Restauração (Restoration War), its defences were adapted for artillery purposes and the Fortress and Ravelin were built on orders from King D. João IV. After the terrible earthquake which devastated Portugal in 1755, King D. José I ordered the castle to be repaired.
In the early 20th century, Castro Marim Castle was classified as a National Monument. It is open to visitors all year round and hosts the annual "Medieval Days" event, when it becomes the stage for the re-enactment of past conquests.