(CNN) Thousands of Cuban migrants are heading to the U.S.-Mexico border as part of a deal with Panama.

The first group of 238 Cuban migrants arrived Monday in the border city of Juarez on two flights from Panama, Mexico's foreign ministry said in a statement.

The agreement will allow Panama to send a total of 3,995 U.S.-bound Cuban migrants to Mexico, where they will be allowed to stay for up to 20 days for "humanitarian reasons" due to "extraordinary circumstances," the ministry said.

Cuban immigration to the United States has spiked amid growing fears that U.S. immigration policies could be changing as relations between the two countries thaw.

Since the 1960s, U.S. law has allowed Cuban refugees who set foot in the United States to live and work in the country without facing the same hurdles immigrants from other countries encounter.

But making it to the United States isn't easy.

Those who are found at sea are returned to Cuba. And an increasing number of countries across Latin America are closing their borders to stop migration.

'A temporary measure'

Cubans wait Tuesday at Panama City's airport for flights to northern Mexico.

Mexico's foreign ministry described the flights from Panama as a "temporary measure."

Cubans who want to take the flights must pay about $800 for their tickets, local media reported, citing government officials.

"At the same time, both countries agreed to put in motion a series of actions to prevent and disincentivize new flows," the foreign ministry said.

Officials haven't detailed what steps they plan to take. But Panama announced Monday that it was temporarily closing its border with Colombia.

It was a difficult decision, Panamanian President Juan Carlos Varela said, but a necessary move to stop what he called "the crossing of irregular migrants."

The deal with Mexico marks at least the third time this year when countries have arranged airlifts of Cuban migrants to allow them to reach the U.S. border.

'I want to reunite with my family'

As they waited for travel documents Tuesday at Panama City's Tocumen International Airport, migrants told TVN that they were grateful and eager to make their way to the United States.

"I am ready to travel and very grateful, very grateful to Panama, with God's grace will be traveling soon. I want to reunite with my family there," one woman said as she stood in line outside the airport.

Migrants are still trying to reach the United States by sea. The U.S. Coast Guard said last year that it was seeing an increase in Cubans trying to reach the United States in rafts.

Eight Cuban migrants made it ashore in South Florida early Tuesday after 11 days at sea in a home-made vessel, police told CNN affiliate WSVN-TV in Miami.

But analysts say more migrants have been taking a different route, flying to South America and trying to reach the United States from there.

In 2015, nearly 26,000 Cubans entered Panama, a fivefold increase over 2014, CNN affiliate TVN reported, citing government figures. This year, migrants are entering Panama at a rate of about 23 a day, TVN reported.

The latest figures provided to CNN by a congressional source show that the number of Cuban migrants seeking refugee status in the United States more than doubled last year.

According to U.S. Customs and Border Protection statistics, 24,477 Cubans were admitted into the United States with refugee status in 2014. That figure nearly doubled in 2015 to 43,154. The figure for this year already stands at 25,806.