Disagreement led to the Costa Rican Civil War of Costa Rica that ended in 1823 when the pro-independence side won and created the capital, San José. An immediate challenge for the country after independence was the need to decide whether to remain independent or join the Mexican Empire.
To date, Costa Ricans celebrate their Independence Day on September 15. However, Costa Rica was already an autonomous Spanish province after adopting the Spanish Constitution of 1812, which the country adopted for a second time in 1820. Costa Rica never fought for independence, but Guatemala declared the independence of all countries in Central America in 1821. The Republic of Costa Rica gained independence on September 15, 1821, as a result of the Mexican War of Independence that lasted from 1810 until 1821.