It was built to defend the main port of the country, as well as the city of Lima from pirates and corsairs during colonial times.
Viceroy José Antonio Manso de Velasco, ordered the construction of the fortress to bolster the defense of the port.
In 1806, viceroy José Fernando de Abascal y Sousa ordered the construction of a storage depot for arms, artillery and water to supply up to 2,000 soldiers for up to four months.
[5] During 16 January 1819, the fortress repulsed an attack from Admiral Lord Thomas Cochrane during the government of viceroy Joaquín de la Pezuela.
The siege ended in 1821, when royalist General José de La Mar surrendered to Republican forces.