The war with Spain in 1640 brought major changes to the fortress. The need to re-fortify the town, which had grown markedly outside the medieval perimeter during the previous three centuries, and the urgency to build a new fortified perimeter to defend the inhabitants of the "new town" from the incursions of the Castilian armies, forced the Kings of Portugal to invest large amounts of money, and to send contingents of military engineers, specialized workers and even more non-specialized workers to strength Campo's defenses. Due to these efforts, the garrison substantially grew in size. It is estimated that, in late 17th Century, one out of four inhabitants of Campo Maior was employed by the military. Campo Maior became the headquarters of the mercenary Dutch troops that fought in Alentejo. The town was at that time the second most important garrison in the Alentejo region, second only to the city of Elvas.