I’m still wrapping my head around the scope of Ecuadorian history – as much as I love history, South America is a huge blind spot in my knowledge. In grade school we did a cursory study of Brazil (the BRIC countries were big as a concept then), but almost zero on the Spanish-speaking countries.
One of the things I’m learning is that there have been many wars between neighbouring countries – Chile’s successful war against Peru and Bolivia that left the latter landlocked, for example. However, Ecuador and Peru take the cake – they were actively disputing a border for almost 200 years, even before either were independent from Spain, and have had multiple wars over that time (mostly resulting in Ecuador losing territory).

The first round was part of the larger internecine wars in the early 1800s between the newly independent countries that followed the wars for independence from Spain – Ecuador was a main battleground in the Gran Colombia-Peru War in 1828-29, which included the shelling of Guayaquil (being a large valuable port city, it’s been fought over a LOT).
After Bolivar and Gran Colombia eventually failed, as one of the successor states, Ecuador tried to settle its share of debts from the War of Independence from Spain. British creditors were given rights to Ecuadorian territory, but that included land in the Amazon basin contested with Peru. So, from 1857-60, there was another war between the two countries, but still no resolution on the border.
Things simmered for a century, until in 1941, things boiled over again into another war. While the 1941 Ecuador-Peru War had nothing officially to do with WWII, it seemed to provide an opportunity for Peru to take advantage of global (particularly American) attention being elsewhere. Ecuador was routed and forced to cede its claims to much of the disputed territory.
Here’s a really good look at the war from the Time Ghost WWII channel (the same people who did The Great War), including a look at the fighting and diplomacy around the war:
Ecuador and Peru’s border disputes continued through the 20th century, with two more small wars – the Paquisha War in 1981 and the Cenepa War in 1995. Here’s a military-focused look at the Cenepa War for additional context:
A peace deal and final settlement of the border between Ecuador and Peru was brokered in 1998 and so far, it has held. Optimistically, Peru and Ecuador sorted out their maritime boundaries peacefully in 2011, have signed bilateral trade deals, started to interconnect their electrical infrastructure, and have pretty positive relations.