<P> In the early 19th century, Napoleon's occupation of Spain led to the outbreak of revolts all across Spanish America . In New Spain, all of the fighting by those seeking independence was done in the center of that area from 1810 to 1821, what today is central Mexico . Once the Viceroy was defeated in the capital city--today Mexico City--in 1821, the news of independence was sent to all the territories of New Spain, including the Intendencies of the former Captaincy of Guatemala . Costa Rica joined the other Central American Intendancies in a joint declaration of independence from Spain, the 1821 Act of Independence . </P> <P> On October 13, 1821 the documents arrived at Cartago, and an emergency meeting was called upon by Governor Juan Manuel de Cañas . There were many ideas on what to do upon gaining independence, such as joining Mexico, joining Guatemala or Nueva Granada (today Colombia). A group was declared (Junta de Legados), which created the temporary Junta Gubernativa Superior . Meanwhile, "the clouds clear up" ("Mientras se aclaraban los nublados del día"), was a famous phrase of the events of the day . </P> <P> Independence from Spain was acknowledged and ratified on October 29, 1821 by the colonial authorities . It was then ratified in the cities of San José on November 1, 1821, at Cartago on November 3rd, 1821, at Heredia on November 11, 1821, and Alajuela on November 25th, 1821 . </P> <P> After the declaration of independence, the New Spain parliament intended to establish a commonwealth whereby the King of Spain, Ferdinand VII, would also be Emperor of New Spain, but in which both countries were to be governed by separate laws and with their own legislative offices . Should the king refuse the position, the law provided for a member of the House of Bourbon to accede to the New Spain throne . Ferdinand VII did not recognize the colony's independence and said that Spain would not allow any other European prince to take the throne of New Spain . </P>

When did costa rica gain independence from spain