By Patricia Zengerle

WASHINGTON (Reuters) - The Obama administration said on Thursday it was repealing 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.

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 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 pooled of trained health workers.

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 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.

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

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.

"With this change we will continue to welcome Cubans as we welcome immigrants from other nations, consistent with our laws. During my Administration, we worked to improve the lives of the Cuban people - inside of Cuba - by providing them with greater access to resources, information and connectivity to the wider world," Obama said in a statement.

Cuban officials said the U.S. policy had promoted illegal migration, people-trafficking and dangerous journeys across the Florida Straits on flimsy vessels.

'FLEEING A BRUTAL REGIME'

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.

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 in the U.S. national interest. "It is a win for taxpayers, border security, and our allies in the Western Hemisphere," he said.

Flake and Leahy both support Obama's moves toward freer trade and travel with Cuba. But Democratic Senator Robert Menendez, a staunch opponent, called Thursday's announcement a betrayal of Cubans fleeing persecution.

"We should never deny a Cuban refugee fleeing a brutal regime entry into the United States," Menendez said.

The end of the "wet foot, dry foot" policy was first reported by the Associated Press, citing a senior Obama administration official.

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.

(Additional reporting by Matt Spetalnick and Eric Beech; Editing by Eric Walsh and Tom Brown)