The wall was built during the Hispanic period to protect the city from pirate attacks, which were a common threat given Trujillo's proximity to the sea (roughly 5 km from the main plaza). Most colonial cities along the northern coast were subject to these attacks. Guayaquil was attacked in June 1624 by the Dutch army under the command of Jean Claude de Gubernat, who received the order from deputy Jaques L’Heremite Clerk. More than 20 houses were burned during the siege. The city also maraudered by William Dampier in 1684, and by French pirates D’Hout, Picard and Groignet in 1687, who left the city half-destroyed. It was also bombarded by pirates from the Peruvian city of Saña. Given the looming threat of attack, the Wall of Trujillo was built in the 17th century during the reign of Viceroy Melchor de Navarra y Rocafull. It was constructed by Italian Joseph Formento in 1687 under the leadership of mayors Bartolomé Martínez de Jarabeitia and Fernando Ramírez de Orellana. Formento based his design on a similar work done by Leonardo da Vinci for the Italian city of Florence.
