On October 9, 1820, the Department of Guayaquil became the first territory in Ecuador to gain its independence from Spain, and it spawned most of the Ecuadorian coastal provinces, establishing itself as an independent state. Its inhabitants celebrated what is now Ecuador's official Independence Day 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. Two years later, it annexed the Galapagos Islands.