PANAMA CITY (Reuters) - Hundreds of Cubans who sold their homes and belongings in pursuit of an American dream that now lays in tatters were stranded in Central America and Mexico on Friday after Washington abruptly ended a lenient immigration policy.

Cuban migrants listen and monitor international news on a cellphone outside the Caritas shelter in Panama City, Panama, January 13, 2017. REUTERS/Melchor Herrera

U.S. President Barack Obama on Thursday repealed a measure granting automatic residency to virtually every Cuban who arrived in the United States, whether or not they had visas, ending a longstanding exception to U.S. policy.

The end of the “wet foot, dry foot” policy, which allowed any Cuban who reached U.S. soil to stay, but returned any picked up at sea, took effect immediately. Cuban officials had long sought the change, arguing it would discourage people-trafficking and dangerous journeys.

Jose Enrique Manreza, who sold his house and possessions in Havana to embark on a epic trip by plane, bus and foot through the rain forests of French Guiana, Colombia and Panama, estimated he had spent about $10,000 on the journey.

“Imagine how I feel, after I spent six days and six nights running through rivers and jungles in the humidity,” said Manreza, at a migrant shelter in the southern Mexican city of Tapachula, where he heard the news, along with 30 other Cubans.

In Honduras, 75 Cubans were waiting to move on to Mexico and the U.S. border. In Panama, another 75 gathered in the tree-shaded patio of the Caritas shelter in the capital. Many had sold everything they owned to pay for the voyage of a lifetime. Some said hundreds more were still traversing the treacherous forests of the Darien region bordering Colombia.

Some expressed dismay that Obama, who is popular in Cuba for punching holes in the U.S. economic embargo and reinstating diplomatic relations, had taken a measure they saw as hurting ordinary Cubans.

“Obama’s decision is killing our dreams,” said Yancys Riccart, 25, a teaching assistant, who said her journey took her through Guyana, Brazil, Ecuador and Colombia. She said she was worried she would be mistreated or not given work by Cuban authorities if she went back home.

Victor Berrios, a deacon for Roman Catholic charity Caritas, urged the migrants not to rush into the hands of people-traffickers to reach the United States, reminding them that U.S. President-elect Donald Trump could reinstate the law when he assumes the presidency on Jan 20.

Slideshow ( 7 images )

“Be patient, we know that from the 20th there will be another government. Do not lose hope. Have faith,” Berrios said.

Washington has unveiled a flurry of last minute agreements to try to prevent Trump reversing the 2014 detente with Cuba, one of Obama’s flagship policies.

Trump has said he would scrap Obama’s Cuba policy unless the Cubans presented a better deal, but it was not immediately clear if he would try to bring back “wet-foot, dry-foot.”

“$10 LEFT IN MY POCKET”

Anticipating the end of the policy, Cuban immigration has surged since the 2014 normalization. Ben Rhodes, Obama’s deputy national security adviser, said some 40,000 Cubans arrived in the United States in 2015 and about 54,000 in 2016.

Thousands of Cubans gathered in Costa Rica and Panama last year as Central American countries struggled to cope with the influx. El Salvador welcomed the new policy, saying all immigrants should be treated equally.

Honduras, a source of thousands of immigrants to the United States each year, despite no Cuban-style special treatment, said it was waiting to see if the policy led to fewer Cubans traveling. Mexico’s foreign ministry had no immediate comment.

Manreza said his wife, a nurse, was working in Venezuela as part of a Cuban oil-for-doctors program. Obama also rolled back a “medical parole” program dating back to 2006 that allowed Cuban doctors working in third countries to move to the United States simply by walking into a U.S. embassy.

“She cried when I called her,” he said, without indicating whether she had intended to defect under the program.

Manreza, who ran a soda warehouse in Havana before he left in December with his daughter, said he was deciding whether to return to Cuba, broke, or seek asylum in Mexico.

Ivan Diaz, 45, a health administrator, said he had no intention of turning back.

He left Cuba three months ago with his wife. He said the dash for the United States had cost about $25,000 for him, his wife and Miami family members who sent money to support them.

“I’ve got $10 left in my pocket,” said Diaz at the Tapachula center. “We are going to carry on. We don’t lose anything by going to the Laredo border. We must be able to do something. Otherwise, let them deport me back to Cuba.”