All these wars depopulated the town and gradually reduced it to rubble. Only with Manuel I in 1521 did Beja again reach the status of city. It was attacked and occupied by the Portuguese and the Spanish armies during the Portuguese Restoration War (1640–1667).