Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Central American nations have reached a deal to let the first of thousands of stranded Cuban migrants continue their journey north toward the United States next month.

The humanitarian transfer will airlift an unspecified number of Cubans the first week of January from Costa Rica to El Salvador, from where they will continue by bus toward Mexico, Costa Rica's Foreign Ministry said in a statement Monday.

The Guatemalan government, which hosted a diplomatic meeting earlier in the day to consider the issue, described it as a "pilot" program and said a work group has been tasked with coordinating logistics.

The Morning Rundown Get a head start on the morning's top stories. This site is protected by recaptcha

The two governments did not immediately release further details, citing some nations' desire for discretion on what has become a diplomatic flashpoint between Costa Rica and neighboring Nicaragua.

The number of Cubans stranded in Costa Rica has reached at least 8,000 since Nicaragua closed its border to them weeks ago. The islanders say they are trying to reach the United States, where favorable migratory policies toward Cubans mean nearly all are allowed to stay and apply for residency.

On Sunday, Pope Francis called for their plight to be resolved.

Costa Rican Foreign Minister Manuel Gonzalez said the measure will be available only to Cubans who are already in Costa Rica. Ministry spokeswoman Melissa Duran told The Associated Press it will be up to the migrants to pay the costs of their travel, but did not give more specifics.

On Dec. 18, Costa Rica stopped issuing transit visas for Cuban migrants and announced that any who arrived after that without a visa would be deported.

Cuba has seen a spike in outward migration in the year since it and Washington announced they would re-establish diplomatic ties after more than five decades of open hostility. Many Cuban migrants say they chose now to emigrate out of fear that detente could bring about an end to the U.S. policies that benefit them - although U.S. officials say no change is in the works.

Cuba and its close ally Nicaragua argue that the U.S. policies toward Cubans encourage them to attempt dangerous migratory routes and cause a brain drain on the island.

Follow NBC News Latino on Facebook, Twitter and Instagram.