In 1809, the fortifications were improved under engineer Manuel de Sousa Ramos, just before they were occupied by Masséna's forces, who destroyed the palace of the Marquess of Abrantes. Afterwards, the castle installations were de-activated as quarters, and converted to a military presidio, resulting in alterations to its structure.
