The Castle of Castro Marim is a medieval castle on a hilltop overlooking the civil parish of Castro Marim, in the municipality of the same name, in the Portuguese Algarve. The castle was part of the defensive line controlled by the Knights Templar, a stronghold used during the Portuguese Reconquista, and adapted during the Restoration War to defend the frontier.