The war ended when a triumphant heavily outnumbered southern Gran Colombian army at Battle of Tarqui dated February 27, 1829, led by Antonio José de Sucre, defeated the Peruvian invasion force led by President La Mar. This defeat led to the signing of the Treaty of Guayaquil dated September 22, 1829, whereby Peru and its Congress recognized Gran Colombian rights over Tumbes, Jaen, and Maynas. Through protocolized meetings between representatives of Peru and Gran Colombia, the border was set as Tumbes river in the west and in the east the Maranon and Amazon rivers were to be followed toward Brazil as the most natural borders between them. However, what was pending was whether the new border around the Jaen region should follow the Chinchipe River or the Huancabamba River. According to the peace negotiations Peru agreed to return Guayaquil, Tumbez, and Jaén; despite this, Peru returned Guayaquil, but failed to return Tumbes and Jaén, alleging that it was not obligated to follow the agreements, since the Gran Colombia ceased to exist when it divided itself into three different nations - Ecuador, Colombia, and Venezuela.