 Peru seems to have remained strongly royalist in large part because of its rivalry with Río de la Plata, to which it had lost control of Upper Peru when the latter was elevated to a viceroyalty in 1776.The creation of juntas in Río de la Plata allowed Peru to regain formal control of Upper Peru for the duration of the wars.The restoration of Ferdinand VII signified an important change, since most of the political and legal changes done on both sides of the Atlantic—the myriad of juntas, the Cortes in Spain and several of the congresses in the Americas that evolved out of the juntas, and the many constitutions and new legal codes—had been done in his name.