Costa Rica was a Spanish colony from the 16th century until 1821. It gained independence from Spain on September 15, 1821, along with other Central American territories that were part of the Captaincy General of Guatemala. Spain was the European colonial power that controlled Costa Rica, not Yugoslavia, the Ottoman Empire, or Belgium.