History of Lima Reforms. The population of Lima played an ambivalent role in the 1821–1824 Peruvian War of Independence; the city suffered exactions from Royalist and Patriot armies alike. After independence, Lima became the capital of the Republic of Peru. It enjoyed a short period of prosperity in the mid-19th century until the 1879–1883 War of the Pacific when it was occupied and looted by Chilean troops. After the war, the city went through a period of demographic expansion and urban renewal. Population growth accelerated in the 1940s spurred by immigration from the Andean regions of Peru. This gave rise to the proliferation
Lima under General José de San Martín landed south of Lima in 1820 but did not attack the city. Faced with a naval blockade and the action of guerrillas on land, Viceroy José de la Serna e Hinojosa evacuated its capital in July 1821 to save the Royalist army. Fearing a popular uprising and lacking any means to impose order, the city council invited San Martín to enter Lima and signed a Declaration of Independence at his request. However, the war was not over; in the next two years the city changed hands several times. After independence, Lima became the capital