Costa Rica was sparsely inhabited by indigenous people before coming under Spanish rule in the 16th century.