Early Tuesday morning, the first of forty-five flights left Costa Rica, carrying a hundred and eighty Cuban migrants to El Salvador, where they boarded buses that travelled north through Guatemala to Mexico. In Mexico, the government granted them temporary visas, which give them twenty days to travel north on their own and cross the U.S. border. Their chances of making it are uncertain, but if they reach the border, they will be granted entry and allowed to apply for green cards within one year of their arrival, as long as they pass standard background checks. In the next three weeks, eight thousand Cubans are scheduled to make the trip, which costs five hundred and fifty-five dollars per person; a travel agency made the plane, food, and bus arrangements, at the behest of the governments of the countries along the route. If the process goes smoothly, the plan could be replicated in Panama, where three thousand Cubans are currently waiting to travel to the U.S.

For several years now, there has been grimly regular news of waves of Latin Americans seeking refuge in the U.S., mostly from El Salvador, Guatemala, and Honduras, where gang and drug violence have surged. At the same time, a stream of Cuban migrants has not commanded the same attention, but has revealed some of the vagaries and inconsistencies of American immigration law. Last year, forty-four thousand Cubans sought asylum in the U.S., an eighty-three-per-cent increase over the previous year. Most left out of concern that the new relations between the two countries could put an end to Cubans’ privileged immigration status, which, since 1966, has allowed them to easily obtain green cards. (The Cuban government has always objected to the American policy.)

Rather than boarding boats to cross the ninety-mile Florida Straits, many of the Cuban migrants have flown south to Ecuador, drawn by the country’s lax visa requirements, and from there travelled overland to the U.S., through Colombia, Panama, Costa Rica, Nicaragua, Guatemala, and Mexico. The reason for their elliptical route is simple: in the mid-nineties, the U.S. created a policy, intended to tamp down Cuban immigration, called “wet foot, dry foot.” If Cubans are caught on the water, the U.S. Coast Guard will send them back to Cuba, but if they show up on land—at the Texas border, for instance—they are granted entry and allowed to apply for a green card.

These migrants have had to navigate different visa requirements along the way, some of which are tougher (and costlier) than others. Still, the trip, in spite of its inevitable dangers, was a straight shot north. Then, two months ago, Nicaragua, which has a close relationship with the Cuban government, and is embroiled in a long-standing border dispute with Costa Rica, started denying Cubans visas. As a result, a growing number of Cubans are stranded south of the Nicaraguan border, in Costa Rica. Even before Nicaragua started denying visas, Costa Rica was struggling to handle the influx of Cuban migrants. This past September, Costa Rican authorities reported that they had stopped twelve thousand undocumented Cubans over the previous year alone. (By comparison, they had stopped fifty in 2011.) And in November, around the time the Nicaraguan government started denying visas, the Costa Rican government dislodged an enormous smuggling operation along its northern border.

Last weekend, I spoke to Katia Rodríguez, the director of Costa Rica’s immigration authority, about the government sting. For nearly ten months, the government tracked at least twelve smugglers in a network that spanned Miami, Ecuador, and Guatemala. “We’ve always had smuggling and illegal immigration, but it was limited to lone coyotes or middle-men,” Rodríguez told me. “This was an international operation of unprecedented scope.” She described an entire criminal hierarchy, with smugglers organized into teams that dealt with cross-country communications, transportation, and payment logistics. Fourteen Cubans, along with twelve Nicaraguans, were detained in a preliminary sweep of several houses near the Nicaraguan border; all of them were eventually deported to Nicaragua, where the Cubans continued north on their journey to the U.S., according to the Tico Times. Rodríguez said that four hundred people were arrested in the operation, and that thousands more eluded roundups in stash houses along the border.

Shortly after the operation, Costa Rica renewed talks with neighboring countries about relieving the strain of processing so many migrants, but it failed to reach a deal that would allow the thousands of stranded Cubans to cross into Nicaragua. So, late last month, seven Central American countries—Panama, Costa Rica, Honduras, El Salvador, Guatemala, Mexico, and Belize—agreed to the airlifts. Rodríguez told me the agreement was strictly provisional, echoing a statement by the Costa Rican foreign minister. Costa Rican authorities have voiced exasperation with Nicaragua, but Rodríguez suggested that her government’s deeper source of frustration is the American policy on Cuban migrants. The Costa Rican flight agreement “exists just because of the U.S. law that grants preferential treatment to some migrants,” she said.

In an effort to slow Cuban migration, the U.S. State Department has maintained that it has no plans to change its policy. There has been no word of any American involvement in the airlift agreement, but at the very least, the seven participating countries could have been confident that the U.S. would not turn the Cubans away at the border. “If it’s a safe-passage scenario we’re talking about, then the U.S. and Mexico have to be involved in the agreement somehow, too,” Eric Farnsworth, a former State Department official, who had been stationed in Nicaragua and Costa Rica, told me. “These countries are trying to create a pipeline to the U.S.”

The preferential treatment for Cuban migrants has created resentment among other Central American immigrants. Tens of thousands of people fleeing violence in Honduras, El Salvador, and Guatemala have arrived in the U.S. since the summer of 2014 and applied for asylum. According to the Times, of the nearly thousand of those cases that judges have heard so far, eighty per cent have ended with deportation. The U.S. has been chartering fourteen flights a week since 2014 to send these migrants back to Central America.

Planes heading south from the U.S. carry deportees, while planes heading north, from Costa Rica, deliver Cuban immigrants most of the way to the U.S. border. “The Obama Administration has two problems,” William LeoGrande, a regional expert and co-author of the book “Backchannel to Cuba,” wrote in an e-mail. “One is the striking contrast between the treatment of Cubans looking for economic opportunity and Central American families fleeing gang violence. The second problem is that the open door for Cubans on the Texas border, combined with the greater freedom to travel the Cuban government has given its people since 2013, means the flow of Cubans through Mexico is not going to diminish anytime soon.”

Last week, the Salvadoran Foreign Minister Hugo Martínez complained to the American press about a double standard. “It’s a policy that allows one set of migrants to be treated in a privileged manner and another set of migrants in a discriminatory fashion,” he said. Geoff Thale, of the Washington Office on Latin America, pointed out to me the insecurity of the Cuban airlift arrangement. “I’m concerned about the humanitarian question of bringing thousands of immigrants to Mexico, and then leaving them to their own devices, where they can be preyed on by smugglers,” he said. One Cuban immigrant told the local press, “We’ve heard a lot that in Mexico there are groups like the Zetas that make attacks on roads.” She said that once she arrived in Mexico she planned to fly to a town closer to the U.S. border, to avoid the risks of crossing the country.