A man runs past a Cuban flag near the United States embassy, behind right, in Havana, Cuba, Thursday, Jan. 12, 2017. President Barack Obama announced Thursday he is ending a longstanding immigration policy that allows any Cuban who makes it to U.S. soil to stay and become a legal resident. (AP Photo/Ramon Espinosa)

A man runs past a Cuban flag near the United States embassy, behind right, in Havana, Cuba, Thursday, Jan. 12, 2017. President Barack Obama announced Thursday he is ending a longstanding immigration policy that allows any Cuban who makes it to U.S. soil to stay and become a legal resident. (AP Photo/Ramon Espinosa)

WASHINGTON (AP) — President Barack Obama announced Thursday he is ending a longstanding immigration policy that allows any Cuban who makes it to U.S. soil to stay and become a legal resident.

The repeal of the “wet foot, dry foot” policy is effective immediately. The decision follows months of negotiations focused in part on getting Cuba to agree to take back people who had arrived in the U.S.

ADVERTISEMENT

“Effective immediately, Cuban nationals who attempt to enter the United States illegally and do not qualify for humanitarian relief will be subject to removal, consistent with U.S. law and enforcement priorities,” Obama said in a statement. “By taking this step, we are treating Cuban migrants the same way we treat migrants from other countries. The Cuban government has agreed to accept the return of Cuban nationals who have been ordered removed, just as it has been accepting the return of migrants interdicted at sea.”

The Cuban government praised the move. In a statement read on state television, it called the signing of the agreement “an important step in advancing relations” between the U.S. and Cuba that “aims to guarantee normal, safe and ordered migration.”

Obama is using an administrative rule change to end the policy. Donald Trump could undo that rule after becoming president next week. He has criticized Obama’s moves to improve relations with Cuba. But ending a policy that has allowed hundreds of thousands of people to come to the United States without a visa also aligns with Trump’s commitment to tough immigration policies.

President Bill Clinton created “wet foot, dry foot” policy in 1995 as a revision of a more liberal immigration policy that allowed Cubans caught at sea to come to the United States become legal residents in a year.

The two governments have been negotiating an end to “wet foot, dry foot” for months and finalized an agreement Thursday. A decades-old U.S. economic embargo, though, remains in place, as does the Cuban Adjustment Act, which lets Cubans become permanent residents a year after legally arriving in the U.S.

Under the terms of the agreement, Cuba has agreed to take back those turned away from the U.S., if the time between their departure from Cuba and the start of deportation hearings in the U.S. is four years or less. Officials said the timeframe is required under a Cuban law enacted after Congress passed the Cuban Adjustment Act.

“For this to work, the Cubans had to agree to take people back,” said Ben Rhodes, Obama’s deputy national security adviser.

Administration officials called on Congress to repeal the Cuban Adjustment Act.

Officials said the changes would not affect a lottery that allows 20,000 Cubans to come to the U.S. legally each year. But Rhodes cast the shift as a necessary step toward Cuba’s economic and political development.

ADVERTISEMENT

“It’s important that Cuba continue to have a young, dynamic population that are clearly serving as agents of change,” he said.

Rhodes also cited an uptick in Cuban migration, particularly across the U.S.-Mexico border — an increase many have attributed to an expectation among Cubans that the Obama administration would soon move to end their special immigration status.

Since October 2012, more than 118,000 Cubans have presented themselves at ports of entry along the border, according to statistics published by the Homeland Security Department, including more than 48,000 people who arrived between October 2015 and November 2016.

Relations between the United States and Cuba were stuck in a Cold War freeze for decades, but Obama and Cuban President Raul Castro established full diplomatic ties and opened embassies in their capitals in 2015. Obama visited Havana last March. Officials from both nations met Thursday in Washington to coordinate efforts to fight human trafficking.

Obama said the Cuban Medical Professional Parole Program, which was started by President George W. Bush in 2006, is also being rescinded. The measure allowed Cuban doctors, nurses and other medical professionals to seek parole in the U.S. while on assignments abroad. The president said those doctors can still apply for asylum at U.S. embassies around the world.

“By providing preferential treatment to Cuban medical personnel, the medical parole program ... risks harming the Cuban people,” Obama said.

People already in the United States and in the pipeline under both “wet foot, dry foot” and the medical parole program will be able to continue the process toward getting legal status.

Reaction to the announcement in Havana was muted Thursday afternoon.

“This was bound to happen at some point,” said taxi driver Guillermo Britos, 35. “It could impose a more normal dynamic on emigration, so that not so many people die at sea, but it could also take an escape valve away from the government, which was getting hard currency from the emigrants.”

Anti-Castro Cubans in Miami were mixed in their responses, with some expressing anger at Obama for what they called another betrayal of ordinary Cubans. Others said they thought the measure would increase pressure for change in Cuba.

“People who can’t leave, they could create internal problems for the regime,” said Jorge Gutierrez, an 80-year-old veteran of the Bay of Pigs invasion. But he added, “From the humanitarian point of view, it’s taking away the possibility of a better future from the people who are struggling in Cuba.”

Rep. Illeana Ros-Lehtinen, a Florida Republican who emigrated from Cuba as a child, decried the elimination of the medical parole programs, calling it a “foolhardy concession to a regime that sends its doctors to foreign nations in a modern-day indentured servitude.”

__

Associated Press writers Matthew Lee and Kevin Freking in Washington, Gisela Salomon and Michael Weissenstein in Miami, Bill Barrow in Atlanta and correspondent Andrea Rodriguez in Havana contributed to this report.

__

Follow Alicia A. Caldwell on Twitter at www.twitter.com/acaldwellap and Julie Pace at www.twitter.com/jpaceDC