The Viceroyalty of Peru (Spanish: Virreinato del Perú) was a Spanish colonial administrative district, created in 1542, that originally contained most of Spanish-ruled South America, governed from the capital of Lima. The Viceroyalty of Peru was one of the two Spanish Viceroyalties in the Americas from the sixteenth to the eighteenth centuries.
The Spanish did not resist the Portuguese expansion of Brazil across the meridian established by the Treaty of Tordesillas. The treaty was rendered meaningless between 1580 and 1640 while Spain controlled Portugal. The creation during the 18th century of Viceroyalties of New Granada and Rio de la Plata (at the expense of Peru's territory) reduced the importance of Lima and shifted the lucrative Andean trade to Buenos Aires, while the fall of the mining and textile production accelerated the progressive decay of the Viceroyalty of Peru. Eventually, the viceroyalty would dissolve, as with much of the Spanish empire, when challenged by national independence movements at the beginning of the nineteenth century. These movements led to the formation of the modern-day countries of Peru, Chile, Colombia, Panama, Ecuador, Bolivia, Paraguay, Uruguay, Argentina, Guyana and Trinidad and Tobago in the territories that at one point or another had constituted the Viceroyalty of Peru.