In 1823, during the First Costa Rican Civil War, Costa Rica was divided into two groups: the Imperialists, who were loyal to the First Mexican Empire, and the Republicans, who wanted independence. For the most part, Alajuela and San José fought against the coup staged by the Republicans in Heredia and Cartago. The Alajuelan side won, and Costa Rica left the Mexican Empire shortly before it dissolved. While Costa Rica was a member of the Federal Republic of Central America in the 1830s, the city of Alajuela was the nation's capital.