The Lima city walls were built by Viceroy Melchor de Navarra y Rocafull between 1684 and 1687 to protect Lima against attacks from pirates and privateers. They included 34 bulwarks and eleven gates (ten at the city and one at the other side of the river); their total cost was estimated at 400,000 Spanish dollars. The walls were torn down in 1872 under the presidency of José Balta as part of the expansion process of the city.
Some sections of the walls of Lima can still be seen today. Part of the wall has been restored at the back of the Church of San Francisco, near the Government Palace; this area now constitutes the public Parque de la Muralla (Park of the Wall). In this park it is possible to observe remains of the wall's foundations. In the 1980s, a developer was beginning excavations at the site near the Rimac River and these walls were discovered and later converted into the park.