Lima was defended by the remnants of the Peruvian army and crowds of civilians in the lines of San Juan and Miraflores. As the invading army advanced, the towns of Chorrillos and Barranco were occupied on January 13 of the same year while the town of Miraflores was captured on the 16 of January, after the Battle of Miraflores; finally the city of Lima was occupied on January 17, 1881 until October 23, 1883 when Miguel Iglesias regained control of the Peruvian government.