On September 15, 1821, Independence from Spain is declared, the news arriving to Costa Rica on October 13 of that year, with the first Government Board being installed in November. In December of that year the first Constitution is signed, and in 1824 Costa Rica becomes a State, at that time being part of the United Provinces of Central America.
After the Declaration of Independence, the four main cities of the country: Cartago, Heredia, San Jose and Alajuela, also felt autonomous from each other, and had disagreements on several points. The Cartago and Heredia conservative leaders were in favor of joining Mexico, while San Jose and Alajuela and their Republican leaders were not in agreement with that position. After a small battle in the Ochomogo Hills in Cartago, the Republicans were victorious, and accession with Mexico was rejected.
On July 25 of 1824, the Nicoya Party (corresponding to most of what is nowadays Guanacaste) decided to join Costa Rica.