during the portuguese restoration war, king john iv of portugal identified the need to strengthen lisbon's defences in the face of attacks by the spanish navy. in 1647 he ordered construction of a fort at caxias to improve the defence of the right bank of the tagus by making possible crossfire with the fort of nossa senhora do vale (our lady of the valley) to the east, now demolished, and the fort of giribita to the west, thus reinforcing the major fort of são julião da barra to the west. antónio luís de meneses, 1st marquis of marialva, was given responsibility for the work.