You might have thought that the thaw between Washington and Havana would cut down the number of Cubans attempting an arduous escape to the United States.

If so, you’d be wrong. There has actually been a 78 percent surge in Cubans arriving in the “land of the free” during the first three quarters of 2015, compared to the same period of 2014. The total for the first nine months of this year is 27,296.

The reason? Many Cubans desperate to leave their island fear that warming relations could lead to the repeal of the 1966 Cuban Adjustment Act. Known as “wet foot, dry foot,” it grants Cuban nationals who reach the US permanent residency after a year. Cuban migrants caught at sea between the countries, however, are usually sent back to Cuba.

And the latest unexpected consequence of that has been pandemonium this week on an out-of-the-way Central American border.

Although many Cubans attempt to reach Florida in rickety boats — like Syrians crossing from Turkey to Greece, although the nearly 100-mile Caribbean trip is much longer — there are other routes.

One of the most common is to fly to Ecuador, which requires no visa for Cuban nationals, and then head north by land. In fact, two-thirds of this year’s Cuban arrivals in the US entered through Laredo, Texas, on the border with Mexico.

The problem is that last week Costa Rica, one of the countries along that route, launched a crackdown on the “coyotes,” or people-smugglers, who are reported to charge from $7,000 to $15,000 per migrant to get them from South America to north of the Rio Grande.

That left some 2,000 Cubans trapped in Costa Rica without the necessary papers to continue their journey north. For humanitarian reasons, Costa Rica issued them temporary visas to pass through the country into neighboring Nicaragua.

Cubans rest at a migration center in Penas Blancas, Costa Rica, on the border with Nicaragua on Monday.

But Nicaragua’s hard-left government is a staunch ally of President Raul Castro in Havana, and is ideologically hostile to Cubans attempting to escape the Castro regime. It has refused to recognize those documents and on Friday closed the border. On Sunday, it used military trucks to deport hundreds of Cubans back to its southern neighbor.

Since then, the Cubans have been protesting at the border crossing, bringing the general flow of people and goods almost to a halt.

Several hundred Cubans are camped out at the border. Another 1,000 are voluntarily in a temporary shelter set up by Costa Rica.

Some of the holed-up migrants were photographed carrying anti-Nicaraguan government signs like this one.

Migrants fleeing Castro's Cuba are calling Nicaraguan President Ortega a "repressive communist."

The Ortega administration is pointing the finger at Costa Rica, in a growing diplomatic spat.

Nicaragua’s powerful first lady, Rosario Murillo, even warned of a “serious crisis unleashed by the irresponsibility of Costa Rica” by encouraging thousands of undocumented Cubans to cross into Nicaragua.

And Managua’s foreign ministry published a statement accusing Costa Rica — a close US ally famous for having no military — of “violating our national territory, our sovereignty.”

The spat is just the latest in a history of tensions between the moderate leftist and strongly democratic Costa Rica and Nicaragua, governed by President Daniel Ortega, who led the Sandinista revolution in the 1980s.

Although he is elected, and Nicaragua is nominally a democracy, Ortega has been frequently accused of authoritarianism and cracking down on critics and the opposition.

Cuban officials, meanwhile, shifted blame at Washington's special policy for Cuban migrants.

“This policy encourages illegal emigration from Cuba to the United States and constitutes a violation of the letter and spirit of the migration accords,” the Cuban government said in a statement.

Washington has avoided taking sides on the issue of the Cubans stuck in Central America.

“We continue to encourage all countries to respect the human rights of migrants and to ensure humane treatment of individuals seeking asylum or other forms of protection in accordance with international law and their own national laws,” the US State Department said in an email to GlobalPost.

But it also noted that governments have a right to turn away migrants who “do not have valid asylum claims or another legal basis to remain in country,” adding: “Any and all returns should be carried out safely, and with dignity.”

Costa Rica has also been playing down the dispute, insisting it has abided by national and international laws in dealing with a humanitarian crisis. Its foreign minister, Manuel Gonzalez Sanz, added that his government had been “cautious” in handling the crisis but largely avoided responding to Nicaragua’s attacks.

Meanwhile, more than 2,000 men, women and children, with not much more than the clothes on their backs, wait anxiously at the border.

Senior Correspondent Simeon Tegel is based in Lima, Peru.