TEL AVIV, Israel — Halofom Sultan went from being jailed in his native Eritrea for opposing the oppressive government to detention in Israel, where he is seeking asylum after fleeing for his life.

So when Israel’s prime minister announced a deal with the United Nations on Monday to resettle tens of thousands of African migrants, Sultan was hopeful.

“There was a little light,” he said. But hours later, Prime Minister Benjamin Netanyahu backtracked, canceling the deal and casting Sultan’s future, and those of thousands of others, once again into uncertainty.

Netanyahu’s stunning reversal was just the latest twist in a policy that has careened from detentions to deportations as Israel struggles with how to deal with the migrants. The country’s 35,000 African migrants have been at the receiving end of those decisions, and the scrapping of the U.N. deal means they must now wait for the next decree by Israel’s government to know their fate.

“It feels like a balloon thrown to the ocean that goes to any direction when the wind blows,” the 38-year-old Sultan said. “All the time a new law, a new amendment, changes every time. So I have no clear option or plan or clear vision of what will happen next.”

The migrants, along with much of Israel, watched in disbelief as Netanyahu went from proudly announcing the U.N. deal live on national TV to shelving it hours later.

In laying out what he described as “a good agreement” that “enables us to solve this problem,” Netanyahu said Israel agreed to cancel the planned expulsion of tens of thousands of African migrants. Instead, he said the deal called for sending half of the migrants to Western nations and allowing the rest to remain in Israel.

After an outcry from hard-line members of his coalition and residents of the poor neighborhoods in southern Tel Aviv where many of the Africans live, Netanyahu suspended the agreement. Then, following a meeting Tuesday with Tel Aviv residents, he nixed the deal entirely.

“After I weighed the pros and cons, I decided to cancel the agreement,” Netanyahu said. “We will continue to work determinedly to exhaust all the options at our disposal to remove the infiltrators.”

The Africans, mainly from war-torn Sudan and dictatorial Eritrea, began arriving in Israel in 2005 through its porous border with Egypt after Egyptian forces violently quashed a refugee demonstration and word spread of safety and job opportunities in Israel. Tens of thousands crossed the desert border, often after enduring dangerous journeys, before Israel completed a barrier in 2012 that stopped the influx.

Since then, Israel has wrestled with how to cope with those already in the country. Many took up menial jobs in hotels and restaurants, and thousands settled in southern Tel Aviv, where Israeli residents began complaining of rising crime.

Hawkish Israeli politicians have labeled them infiltrators, with one calling them “a cancer” threatening the country’s Jewish character. Israel has gone from detaining them in remote desert prisons to purportedly reaching a deal with a third country, believed to be Rwanda, to have them deported. All the while, Israel has faced legal challenges, with the U.N. deal offering a potential solution to a yearslong saga that has divided the country.

Critics at home and in the Jewish American community had called the earlier plan to deport the migrants to a third country unethical and a stain on Israel’s image as a refuge for Jewish migrants. Groups of Israeli doctors, academics, Holocaust survivors, rabbis, poets and pilots all appealed to halt the plan.

Israel considers the vast majority of the migrants to be job-seekers and says it has no legal obligation to keep them. The Africans say they are asylum-seekers who fled for their lives and face renewed danger if they return.

Dror Sadot, spokeswoman for The Hotline for Refugees and Migrants advocacy group, said the fate of the asylum-seekers remains unclear since Netanyahu himself acknowledged that there is no deal with Rwanda and has yet to come up with any alternative policy.

“Of course we will continue our struggle and consider all our legal options until every last asylum-seeker gets the status they deserve,” she said.

On Tuesday, migrants milled about southern Tel Aviv, shopping in stores carrying African goods and ducking into shops selling phone cards. Competing posters hanging from balconies carried messages for and against deporting the migrants.

Sultan, the Eritrean migrant, said he left his homeland in the Horn of Africa because he was in danger. He had been jailed several times for his opposition to the government and feared his life was at risk if he stayed any longer.

He left on a perilous journey, leaving his wife and young children in Eritrea while he sought safety. He hasn’t seen his family, now in an Ethiopian refugee camp, since he fled in 2010.

He has worked in Israeli coffee shops and construction sites to make ends meet. Last year, he was sent to Israel’s Holot detention facility, where he was held for a year as part of Israel’s migrant policy. Now unemployed, he spends his time as a community organizer working to better conditions and seek a solution for his fellow migrants.

He accused Netanyahu of playing politics and urged Israel to find a solution. “I want to make clear this is a humanitarian case, not a political issue,” he said.

Following up on a demonstration last month that drew thousands, the migrants responded to Netanyahu’s announcement Tuesday that he was scrapping the deal by protesting outside his office in Jerusalem and in central Tel Aviv.

“As an asylum seeker, as a human being, I’m continuing to fight,” said Sultan. “I hope with the help of the Israeli society there will be a solution.”