 During most of the colonial period, Costa Rica was the southernmost province of the Captaincy General of Guatemala, which was nominally part of the Viceroyalty of New Spain (i.e., Mexico).In practice it operated as a largely autonomous entity within the Spanish Empire.Costa Rica's distance from the capital in Guatemala, its legal prohibition under Spanish law against trading with its southern neighbors in Panama, then part of the Viceroyalty of New Granada (i.e., Colombia), and the lack of resources such as gold and silver, resulted in Costa Rica attracting few inhabitants.