Coffee was first planted in Costa Rica in the early 19th century, and was first shipped to Europe in 1843, soon becoming Costa Rica's first major export. Coffee production would remain Costa Rica's principal source of wealth well into the 20th century. Most of the coffee exported was grown around the main centers of population in the Central Plateau and then transported by oxcart to the Pacific port of Puntarenas. Since the main market for the coffee was in Europe, it soon became a high priority to develop a transportation route from the Central Plateau to the Atlantic Ocean. For this purpose, in the 1870s, the Costa Rican government contracted with U.S. businessman Minor C. Keith to build a railroad to the Caribbean port of Limón. Despite enormous difficulties with construction, disease, and financing, the railroad was completed in 1890.
Most Afro-Costa Ricans, who constitute about 3% of the country's population, descend from Jamaican immigrants who worked in the construction of that railway. U.S. convicts, Italians and Chinese immigrants also participated in the construction project. In exchange for completing the railroad, the Costa Rican government granted Keith large tracts of land and a lease on the train route, which he used to produce bananas and export them to the United States. As a result, bananas came to rival coffee as the principal Costa Rican export, while foreign-owned corporations (including the United Fruit Company) began to hold a major role in the national economy.