History of Lima as it was designated capital of the Viceroyalty of Peru and site of a "Real Audiencia" in 1543. Latin America and Lima's first university, the National University of San Marcos was established in 1551 and its first printing press in 1584. Lima also became an important religious center, a Roman Catholic diocese was established in 1541 and converted to an archdiocese five years later. In 1609, the city held celebrations for the beatification of Ignatius of Loyola. Lima flourished during the 17th century as the center of an extensive trade network which integrated the Viceroyalty of Peru with the Americas,
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