Independence from Spain thumb|Gregorio José Ramírez was the most notable political chief of the province of Costa Rica, leading republican forces victorious in the Battle of Ochomogo. 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 General of Guatemala. Costa Rica joined the other Central American Intendancies in a joint declaration of independence from Spain, the 1821 Act of Independence.
Independence from Spain thumb|Gregorio José Ramírez was the most notable political chief of the province of Costa Rica, leading republican forces victorious in the Battle of Ochomogo. 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 th,ose 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 General of Guatemala. Costa Rica joined the other Central American Intendancies in a joint declaration of independence from Spain, the 1821 Act of Independence.