WASHINGTON (Reuters) - The Obama administration 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. immigration policy.

People gather inside a shop in downtown Havana, Cuba, January 12, 2017. REUTERS/Alexandre Meneghini

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, is effective immediately. Cuban officials had sought the change for years.

The shift had been in the works for months. It was announced abruptly because advance warning might have inspired thousands more people to take to the seas between the Communist-ruled island and Florida in order to beat a deadline.

The United States and Cuba spent several months negotiating the change, including an agreement from Cuba to allow those turned away from the United States to return.

“With this change we will continue to welcome Cubans as we welcome immigrants from other nations, consistent with our laws,” Obama said in a statement.

The Department of Homeland Security also ended a parole program that allowed entry for Cuban medical professionals. That program was unpopular with Havana because it prompted doctors to leave, sapping the country’s pool of trained health workers.

The U.S. Coast Guard intercepts thousands of Cubans attempting the 90-mile (145-km) crossing to Florida every year, but tens of thousands who reach U.S. soil, including via Mexico, have been allowed to stay in the country, while immigrants from other nations have been rounded up and sent home.

Cuba welcomed the policy changes, saying they would benefit the whole region by discouraging people-trafficking and dangerous journeys that led to bottlenecks of Cubans in Central America last year.

“Today, a detonator of immigration crises is eliminated. The United States achieves legal, secure and ordered migration from Cuba,” said Josefina Vidal, the Cuban foreign ministry’s chief for U.S. affairs.

El Salvador’s foreign ministry also welcomed the move, saying “there cannot be migrants of different categories.” Honduras, from where thousands flee each year without the attraction of favorable U.S. immigration policies, said it would wait to see if the flow of Cubans actually reduced.

Anticipating the end of the policy, Cuban immigration has surged since the 2014 normalization, said Ben Rhodes, Obama’s deputy national security adviser.

Slideshow ( 7 images )

“People were motivated to migrate,” Rhodes told reporters on a call, noting some 40,000 Cubans arrived in 2015 and about 54,000 in 2016.

The administration had rejected Cuban entreaties to overturn the policy before President Barack Obama’s historic visit to the island last year, although even some White House aides argued that it was outmoded given efforts to regularize relations between the former Cold War foes.

“Wet foot, dry foot” began in 1995 under President Bill Clinton after an exodus of tens of thousands of Cubans who were picked up at sea by the Coast Guard as they tried to reach Florida.

Obama has been working to normalize relations with Cuba since he and President Raul Castro announced a breakthrough in diplomatic relations in December 2014. His administration has eased restrictions on travel and trade, allowing more U.S. business with Cuba and improved communications with the island.

“MIXED EMOTIONS IN LITTLE HAVANA”

The move to end the policy comes just eight days before the Democratic president turns the White House over to Republican Donald Trump, who has said the United States should get more concessions from Havana in exchange for improved relations.

U.S. immigration policy has given Cubans benefits granted to nationals from no other country. Until now, virtually every Cuban who made it to U.S. soil was granted the right to stay in the country, the right to apply for work permits and, later, green cards, which convey lawful permanent residency.

Jeh Johnson, secretary of Homeland Security, said on a call that Cuba will take back citizens as long as less than four years have passed between the time the migrant left Cuba and the start of the U.S. deportation proceedings.

Under the agreement Cuba will take back some 2,700 people who left the island among 125,000 others during the Mariel boat lift of 1980, fulfilling an agreement made in 1984 to take back 2,746 people who the United States did not grant citizenship to, mainly people with criminal convictions.

Cuba has previously taken back only a handful of that group.

The new policy sparked mixed emotions in Miami’s Little Havana neighborhood.

Mario Garcia, a Cuban mechanic in Little Havana, said the change angered him.

“It’s not like Communism has ended in Cuba, so why stop this that has saved people’s lives?” he said.

But Eulalia Jimenez, who is Venezuelan, said the policy was not fair to migrants from other countries who also flee bad conditions.

“Why should only the Cuban people be able to come and make a life for themselves?” Jimenez said.

Some U.S. lawmakers had been demanding a fresh look at the immigration rules, saying Cubans coming to the United States simply for economic reasons should not be automatically granted benefits intended for refugees.

“This is a welcome step in reforming an illogical and discriminatory policy that contrasted starkly with the treatment of deserving refugees from other countries,” Senator Patrick Leahy, a Democrat, said in a statement.

Republican Senator Jeff Flake also said eliminating the policy was “a win for taxpayers, border security and our allies in the Western Hemisphere.”

Flake and Leahy both support Obama’s moves toward freer trade and travel with Cuba. But U.S. Senator Marco Rubio said the incoming Trump adminstration should reverse the part of the executive order that ended the medical parole system, and said Cubans fleeing political persecution should receive asylum.

The Department of Homeland Security is also eliminating an exemption that prevented the use of expedited removal programs for Cuban nationals picked up at ports of entry or near the border.

But an existing Cuban Family Reunification Parole Program is not affected by Thursday’s announcement and remains in effect.