The Spanish Empire conquered the region in the 16th century and established a viceroyalty that encompassed most of its South American territories, with its capital in Lima. Higher education started in the Americas with the official establishment of the National University of San Marcos in Lima in 1551. Peru formally proclaimed independence in 1821, and following the foreign military campaigns of José de San Martín and Simón Bolívar, and the decisive battle of Ayacucho, Peru completed its independence in 1824. In the ensuing years, the country enjoyed relative economic and political stability, which ended shortly before the War of the Pacific (1879–1884) with Chile. Throughout the 20th century, Peru endured armed territorial disputes, coups, social unrest, and internal conflicts, as well as periods of stability and economic upswing. In the 1990s, the country implemented a neoliberal economic model which is still in use to this day. Since then, Peru has experienced constant economic growth and a decrease in inequality.