The Ecuadorian–Peruvian territorial dispute was a territorial dispute between Ecuador and Peru, which, until 1928, also included Colombia.Ecuador and Colombia signed the Muñoz Vernaza-Suárez Treaty in 1916, ending their dispute, while Peru and Colombia's Salomon-Lozano Treaty became effective in 1928 The dispute had its origins on each country's interpretation of what Real Cedulas Spain used to precisely define its colonial territories in the Americas. After independence, all of Spain's colonial territories signed and agreed to proclaim their limits in the basis of the principle of uti possidetis juris, which regarded the Spanish borders of 1810 as the borders of the new republics. However, conflicting claims and disagreements between the newly formed countries eventually escalated to the point of armed conflicts on several occasions.

The dispute de jure had come to an end in the aftermath of the Ecuadorian–Peruvian War with the signing of the Rio de Janeiro Protocol on January 29, 1942. However, this treaty was also questioned, and the two countries went to war on two more occasions: the Paquisha War in 1981, and the Cenepa War in 1995. Tensions subsided but persisted over the next three years. On October 26, 1998, Ecuador and Peru signed a comprehensive peace accord that established a framework for ending a border dispute. Formal demarcation of border regions started on May 13, 1999. The agreement was ratified without opposition by the congresses of both nations, finally bringing a definitive end to the dispute.

Spanish era

Spanish conquest and establishment of the Viceroyalty of Peru Beginning with the arrival of Christopher Columbus in 1492, the Spanish conquistadores expanded the range of the Spanish Crown's reach from early small settlements in the Caribbean to various continental territories, eventually including Central America and most of South America.

The Spaniards arrived at the borders of the Inca Empire in 1528, and on November 16, 1532, taking advantage of the Inca Civil War, the tiny army of Francisco Pizarro began the Spanish conquest of Peru. In the following decades, Spain consolidated its power over the entire Andean region, repressing successive indigenous rebellions.

To govern the new territories of Spain, in 1542 Holy Roman Emperor Charles V (King Charles I of Spain) created two Viceroyalties, the Viceroyalty of New Spain (in modern-day Mexico) and the Viceroyalty of Peru (a.k.a. the Viceroyalty of New Castile). In 1542, King Charles named Blasco Núñez Vela Peru's first viceroy, but the viceroyalty was not organized until the arrival of Viceroy Francisco de Toledo in 1572. Toledo promptly declared war on Vilcabamba, the last refuge of the Inca; soon afterwards, Tupac Amaru, the last Inca emperor, was captured and executed in Cuzco.

Territorial division of the Viceroyalty of Peru

Because the territory of the Viceroyalty of Peru was so large, and far away from centers of government in Lima and Santo Domingo, Peru (as well as New Spain) was divided into a number of real audiencias (royal audiences), a type of superior judicial tribunal that combined executive and judicial authority, and can be considered "major provinces". The audiences controlled the gobernaciones,Defined as "the civil, as distinguished from the military, branch of the colonial governmental entities lesser in extent than the audiencias." (1910) alcaldias mayores,Defined as "the jurisdiction of the Alcalde mayor, who, as mayor, governed a town of lesser importance than the capital of a province." (1910) corregimientos,Defined as "the district governed by a Corregidor, a correctional magistrate, who, in colonial times, exercised administrative functions over a district. (1910) and alcaldias ordinarias.Defined as "jurisdiction of the Alcalde ordinario, who was similar to the alcaldia mayor, but of lesser extent. (1910) The territory was also divided ecclesiastically, into archbishoprics, religious provinces, suffragan bishopries, parishes and curateships. The archbishoprics and religious provinces corresponded with the audiences, the bishoprics with the gobernaciones and alcaldias mayores, and the parishes and curateships with the corregimientos and alcaldias ordinarias.Paredes-Van Dyke p.8.

These civil divisions were not uniform, with numerous exceptions being made based on the specific circumstances. The Viceroys were presidents of the audiences at the capitals of their Viceroyalties, with other audiences being presided over by captain-generals, or by persons known as gowned presidents. Power was devolved to the captain-general of an audience by the Viceroy, and the audience's territory was administered by the audience's president and the political, military, and religious officials underneath him.

Between 1542 and 1717, the Viceroyalty controlled most of the territory of South America (save for a few non-Spanish colonies and the Commandancy General of Caracas, which was a dependency of the Captaincy General of Santo Domingo). The territory was divided among (noting dates of creation):

Royal Audience of Tierra Firme (1564) Royal Audience of Santa Fe de Bogotá (1548) Royal Audience of San Francisco of Quito (1563) Royal Audience of the City of Kings Lima (1543) Royal Audience of La Plata de los Charcas (1559) Royal Audience of Chile (1563–1573; 1606)

The district of an audience was established in the royal decree by which it was created; the laws laid out in the myriad of Cédulas Reales issued by the Spanish Crown were compiled several times throughout the centuries-long history of Spanish presence in the region. These compilations were referred to as the Laws of the Indies; the 1680 compilation, organized under Charles II, known as the Recopilación de las Leyes de los Reynos de Indias (Compilation of the Laws of the Kingdoms of the Indies), set a template by which the laws were organized.

Under Title XV of Book II of the Recopilación, the limits of the audiences of Lima and Quito were defined as follows:

Creation of New Granada

The two original Spanish viceroyalties of New Spain and Peru had existed intact up until 1717, when King Philip V of Spain issued the Real Cédula of May 27, 1717. The order split off the northwestern corner of Peru and created the Viceroyalty of New Granada. New Granada shared its capital with the Royal Audience of Santa Fé de Bogotá, and additionally had jurisdiction over the New Kingdom of Granada, as well as the audiences of Tierra Firme (now called Panama), Quito, and the Captaincy General of Venezuela. The territories of the Viceroyalty comprised the territories of, respectively, the modern Republics of Colombia, Ecuador, Panama, and Venezuela, as well as the northern regions of Peru, the Brazilian northwest, and the western part of Guyana.

The Royal Audience of Quito had been established by a royal decree in 1563, its territory including Pasto, Popayán, Cali, Buenaventura and Buga in what is currently Colombia, and extended as far south as Piura in what is now Peru. The eastern limit was ill-defined at the time, due to a lack of geographical knowledge and the low importance given to unpopulated, hard-to-reach territories. As the Jesuit Missionaries from Quito and other missionaries entered the Amazon Basin, the Amazon region with its tributaries were more clearly defined and by 1740, the Real Cedula of 1740 precisely defined the borders between the Viceroyalties of New Granada and Peru.

Having temporarily suppressed the Viceroyalty of New Granada, on November 5, 1723, Philip V emitted another Cédula, which returned control of the Royal Audience of Quito to the Viceroyalty of Peru. The Cédula of August 20, 1739 (also called the Cédula de Reerección Definitiva del Virreinato de Nueva Granada, "Definitive Decree of Re-erection of the Viceroyalty of New Granada") reinstated the viceroyalty with its 1717 territories, including the Royal Audience of Quito. The border between Quito and the Viceroyalty of Peru was defined in 1740 by another Cédula:

This cedula greatly modified the original demarcation, but served only to fix the starting point of the line on the pacific coast at the river Tumbes. This document was the first mention of the Tumbes as the boundary between the two viceroyalties.

Real Cédula of 1802

Don Francisco de Requena requested that control of the Government and Commandancy General of Maynas pass from the Viceroyalty of Santa Fe (New Granada) to the Viceroyalty of Peru. In response, on July 15, 1802, the Spanish crown under the rule of Charles IV of Spain issued the Real Cédula of 1802. The decree split the Government and Commandancy General of Maynas and the Governorate of Quijos from the Audience of Quito, and added them to the Viceroyalty of Peru.Luciano p.6 The text of the decree, as reproduced in the Annals of the diplomatic and consular missions of Colombia (1901), reads:

In a footnote, Dr. Antonio José Uribe, Minister of Foreign Affairs of Colombia from 1901 to 1902, wrote,

thereby casting suspicion on the authenticity of one or more of the copies of the document, complicating the already difficult matter of interpreting its meaning.Bowman, p.759: "A royal cedula, dated 1802, complicated matters ... [there] was considerable uncertainty as to the validity of the cedula as well as its meaning..." (This paper was published in 1942, and establishes uncertainty of the Cedula's authenticity at least up until that date.)

According to Pedro Moncayo y Esparza, a 19th-century Ecuadorian writer, the Viceroy of Santa Fe and the President of Quito objected to the execution of the Real Cédula of 1802, as it had all the makings of an apocryphal document: it was not registered in the official cedulario, and its contents could not be found in the Recopilacion de Indias, nor had it been located in the Archive of the Indies in Spain.Luciano p.7 However, during the Peruvian congressional committee hearings regarding the dismissal of the Treaty of Mapasingue, signed between Ecuador and Peru at the end of the war of 1857–1860, it was stated that the Real Cédula of 1802 and the documents proving its execution were found in the archives of the ancient government of Maynas.Paredes & Van Dyke, p.259

The lack of clarity within the document as to whether the transfer of administrative power was purely military and ecclesiastical in nature, or territorial as well, formed the basis for an imprecise territorial situation between Ecuador and Peru when the two nations obtained their independence from Spain.

1803–1818

1803: A similar event occurred in 1803, when it was decided that the military affairs of the Province of Guayaquil (whose capital was the strategically situated port city of Guayaquil) would be run from Lima. 1810: all administrative and economic affairs of the province were turned over to the Viceroyalty of Peru, a state of affairs that would endure until 1819. Jaén de Bracamoros had no such cedula transferring it to Peru and would rightly belong to Ecuador. However, Jaén decided to join Peru after it took part in northern Peru's revolutionary wars of independence. September 28, 1812: the Council of Regency requested from Madrid the Expediente sobre la erección del Obispado de Maynas y las Cédulas que se expedieron en 1805 acerca de los limites ("File on the erection of the Diocese of Maynas and the Decrees that were issued in 1805 regarding the borders"). With no response forthcoming, a Decree of the Courts rendered the Decree of 1802 null and void on November 13, 1812. September 13, 1813: the Real Cédula de 1813 was issued to replace the 1802 decree, in its first article ordering "entregar al Ordinario las nuevas Reducciones y Doctrinas que tuviesen mas de 10 años de antiguedad, proveyéndose en eclesiásticos seculares, conforme a las Leyes del Patronato."