Under the supervision of António Luís de Meneses, 1st Marquis of Marialva, the fort was constructed during the reign of King John IV in a Mannerist style, following an irregular pentagon design. This was done in order to reinforce the defence of the capital in the context of the Restoration War between 1640 and 1668, that culminated in the Treaty of Lisbon (1668) with Spanish recognition of Portuguese sovereignty. It was built to support the Fort of São Julião da Barra to its southwest, crossing fire with the Fort of São Lourenço do Bugio, situated in the middle of the estuary, and the Fort of Santo Amaro do Areeiro, situated between it and São Julião da Barra. It thus formed part of a line of fortifications that stretched from Cabo da Roca on the Atlantic coast to the Belém Tower, close to Lisbon. Its strategic position dominated the channel through which shipping still passes today to avoid shallow bars close to the banks. In 1644 it was already garrisoned by twenty soldiers, ten gunners and a chief of artillery, with five cannons, but the works were only completed in 1653.