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 Río 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 country of Peru, as well as Chile, Colombia, Panama, Ecuador, Bolivia, Paraguay, Uruguay, and Argentina, the territories that at one point or another had constituted the Viceroyalty of Peru.