Panama has closed its border to Cuban immigrants trying to make their way north to the United States and once again is flying Cubans who already made it to the country to the Mexico-U.S. border.

President Juan Carlos Varela said Monday he had agreed with his Mexican counterpart to fly 3,800 Cubans already stranded for weeks while trying to get to the U.S.

Varela says it was a difficult decision, but necessary because Nicaragua closed its border to Cubans last year and impeded their journey north. Cubans are admitted to the United States. if they get to the border. They have been arriving in greater numbers because they fear warming relations between the two countries end the exceptional policy.

Varela says the flights could last two or three weeks.