On October 9, 1820, Guayaquil became the first city in Ecuador to gain its independence from Spain. The people were very happy about the independence and celebrated, which is now Ecuador's independence day, officially on May 24, 1822. The rest of Ecuador gained its independence after Antonio José de Sucre defeated the Spanish Royalist forces at the Battle of Pichincha, near Quito. Following the battle, Ecuador joined Simón Bolívar's Republic of Gran Colombia, also including modern-day Colombia, Venezuela and Panama. In 1830 Ecuador separated from Gran Colombia and became an independent republic.
The 19th century was marked by instability for Ecuador with a rapid succession of rulers. The first president of Ecuador was the Venezuelan-born Juan José Flores, who was ultimately deposed, followed by several 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