The present fort was constructed when King John IV ordered the strengthening of Portugal’s Atlantic defences in the face of attacks by the Spanish navy during the Restoration War (1640-68). In many cases this involved restructuring earlier forts and increasing their firepower. The king appointed João de Cosmander, a Dutch Jesuit military engineer, to supervise construction of the new fortress on the site of the earlier fort built by King Manuel I, with the intention that it would be capable of protecting the fishing harbour of Sesimbra from piracy and from Spanish attacks. Cosmander also worked on the Castle of Campo Maior, the Castle of Belver, and the Castle of Elvas, all major forts in Portugal.