Through a succession of wars and marriages among the nations that inhabited the valley, the region became part of the Inca Empire. Atahualpa, one of the sons of the Inca emperor Huayna Capac, could not receive the crown of the Empire since the emperor had another son, Huascar, born in Cusco, the capital of the Inca Empire. Upon Huayna Capac's death, the empire was divided in two: Atahualpa received the north, with his capital in Quito; Huascar received the south, with its capital in Cusco. In 1530, Atahualpa defeated Huascar and conquered the entire Empire for the crown of Quito.
Barely a year later, in 1531, the Spanish conquistadors, under Francisco Pizarro, arrived to find an Inca empire torn by civil war. Atahualpa wanted to reestablish a unified Incan empire; the Spanish, however, had conquest intentions and established themselves in a fort in Cajamarca, captured Atahualpa during the Battle of Cajamarca, and held him for ransom. The Incas filled one room with gold and two with silver to secure his release. Despite being surrounded and vastly outnumbered, the Spanish executed Atahualpa. To escape the confines of the fort, the Spaniards fired all their cannons and broke through the lines of the bewildered Incans. In subsequent years, the Spanish colonists became the new elite, centering their power in the vice-royalties of Nueva Granada and Lima.
The indigenous population was decimated by disease during the first decades of Spanish rule — a time when the natives also were forced into the "encomienda" labor system for Spanish landlords. In 1563, Quito became the seat of a royal audiencia (administrative district) of Spain and part of the Vice-Royalty of Lima, and later the Vice-Royalty of Nueva Granada.
After nearly three hundred years of Spanish colonization, Quito was a city of ten thousand inhabitants. It was there, on August 10, 1809 (the national holiday), that the first call for independence from Spain was made in Latin America ("Primer Grito de la Independencia"), under the leadership of the city's criollos like Carlos Montúfar, Eugenio Espejo and Bishop Cuero y Caicedo. Quito's nickname, "Luz de América" ("Light of America"), comes from the idea that this first attempt produced the inspiration for the rest of Spanish America, creating a domino effect that would ultimately lead to the expulsion of Spain from the continent.
On October 9, 1820, Guayaquil became the first city in Ecuador to gain its independence from Spain. It was not until May 24, 1822, that the rest of Ecuador gained its independence after Field Marshal Antonio José de Sucre defeated the Spaniard Royalist forces at the Batalla del Pichincha (Battle of Pichincha) near Quito. Following the battle, Ecuador joined Simón Bolívar's Republic of Gran Colombia, only to become a republic in 1830.
The 19th century for Ecuador was marked by instability, with a rapid succession of rulers. The first president of Ecuador was the Venezuelan born Juan José Flores, who was ultimately deposed, followed by many authoritarian leaders such as Vicente Rocafuerte, José Joaquín de Olmedo, José María Urbina, Diego Noboa, Pedro José de Arteta, Manuel de Ascásubi and Flores's own son, Antonio Flores Jijón, among others. The conservative Gabriel Garcia Moreno unified the country in the 1860s with the support of the Roman Catholic Church. In the late 19th century, world demand for cocoa tied the economy to commodity exports and led to migrations from the highlands to the agricultural frontier on the coast.
A coastal-based liberal revolution in 1895 under Eloy Alfaro reduced the power of the clergy and the conservative land owners of the highlands, and this liberal wing retained power until the military "Julian Revolution" of 1925. The 1930s and 1940s were marked by instability and emergence of populist politicians such as five-time President José María Velasco Ibarra.
Control over territory in the Amazon basin led to a long-lasting dispute between Ecuador and Peru. In 1941, amid fast-growing tensions between the two countries, war broke out. Peru claimed that Ecuador's military presence in Peruvian-claimed territory was an invasion; Ecuador, for its part, claimed that Peru had invaded Ecuador. In July 1941, troops were mobilized in both countries. Peru had an army of 11,681 troops who faced a poorly-supplied and inadequately-armed Ecuadorean force of 5,300, of which only 1,300 were deployed in the southern provinces. Hostilities erupted on July 5, 1941, when Peruvian forces crossed the Zarumilla river at several locations, testing the strength and resolve of the Ecuadorean border troops. Finally, on July 23, 1941, the Peruvians launched a major invasion, crossing the Zarumilla river in force and advancing into the Ecuadorean province of El Oro.
During the course of the war, Peru gained control over all the disputed territory and occupied the Ecuadorean province of El Oro, now Tumbes, and some parts of the province of Loja (65 percent of the former country), demanding that the Ecuadorean government give up its territorial claims. The Peruvian Navy blocked the port of Guayaquil, cutting supplies to the Ecuadorean troops. After a few weeks of war and under pressure by the U.S. and several Latin American nations, all fighting came to a stop. Ecuador and Peru came to an accord formalized in the Rio Protocol, signed on January 29, 1942, in favor of hemispheric unity against the Axis Powers in World War II. As a result of its victory, Peru was awarded the disputed territory.
Due to the fact that a small river in the conflict region was not cataloged in the Rio de Janeiro Protocol, Ecuadorian governments believed the Rio Protocol was not valid. It would take two more undeclared wars before a peace agreement was finally reached in 1998 to end hostilities. (See Paquisha Incident and Cenepa War.)
Recession and popular unrest led to a return to populist politics and domestic military interventions in the 1960s, while foreign companies developed oil resources in the Ecuadorean Amazon. In 1972, construction of the Andean pipeline was completed. The pipeline brought oil from the east side of the Andes to the coast, making Ecuador South America's second largest oil exporter. That same year a "revolutionary and nationalist" military junta overthrew the government, remaining in power until 1979, when elections were held under a new Constitution. Jaime Roldós Aguilera was elected President, governing until May 24, 1981, when he died in a plane crash. By 1982, the government of Osvaldo Hurtado faced an economic crisis, characterized by high inflation, budget deficits, a falling currency, mounting debt service, and uncompetitive industries, leading to chronic government instability.
Many years of mismanagement, starting with the mishandling of the country's debt during the 1970s military regime, had left the country essentially ungovernable. Since the mid 1990s, the government of Ecuador has been characterized by a weak executive branch that struggles to appease the ruling classes represented in the legislative and judiciary. The three democratically elected presidents during the period 1996-2006 all failed to finish their terms.
The emergence of the indigenous population (approximately 25%) as an active constituency has added to the democratic volatility of the country in recent years. The population have been motivated by government failures to deliver on promises of land reform, lower unemployment and provision of social services, and historical exploitation by the land-holding elite.