JERUSALEM — Israel announced a deal with the UN on Monday to resettle African migrants in Western nations, but hours later put the agreement on hold.

Prime Minister Benjamin Netanyahu had announced the deal on national TV, saying Israel agreed to cancel the planned expulsion of tens of thousands of African migrants. He said the deal with the United Nations called for sending half of them to Western nations and allowing the rest to remain in Israel.

Late Monday, Netanyahu said he was “suspending” the deal in order to discuss the arrangement Tuesday with Israeli residents of south Tel Aviv areas with large migrant populations.

“After meeting with the representatives I will re-examine the agreement again,” he said.

Under the deal, roughly half of the 35,000 migrants living in Israel would be resettled in the West. But the rest would stay in Israel.

The migrant community is concentrated in south Tel Aviv, angering longtime Israeli residents of the working-class area. Israeli hard-liners had criticized the deal for allowing so many Africans to remain.

The late-night turnaround threw into limbo the surprise agreement, which had finally offered a solution to an issue that has divided Israel for a decade. The deportation plan had been widely criticized at home and abroad, even by some of Israel’s closest supporters.

“It’s a good agreement,” Netanyahu told reporters earlier in the day. “It enables us to solve this problem in a way that serves, protects the interests of the state of Israel and gives a solution to the residents of southern Tel Aviv and other neighbourhoods, and also for the people who came into Israel.”

Most of the African migrants are from war-torn Sudan and Eritrea, the latter having one of the world’s worst human rights records. The migrants say they are asylum-seekers fleeing danger and persecution, while Israeli leaders have claimed they are merely job seekers.

The Africans started arriving in 2005, after neighbouring Egypt violently quashed a refugee demonstration and word spread of safety and job opportunities in Israel. Tens of thousands crossed the porous desert border with Egypt before Israel completed a barrier in 2012 that stopped the influx.

Israel has struggled with what to do with those already in the country, alternating between plans to deport them and offering them menial jobs in hotels and local municipalities.

Due to the large migrant presence, poor neighbourhoods in south Tel Aviv have become known as “Little Africa.” Working-class Jewish residents have complained of rising crime and pressed the government to take action.

But the migrants also found wide pockets of support, with many Israelis arguing that the country, founded in the wake of the Holocaust, had a special responsibility to help those in need.

Thousands of Africans and their Israeli supporters held a demonstration in February claiming the deportation plan amounted to racism. Groups of Israeli doctors, academics, poets, Holocaust survivors, rabbis and pilots also objected to the planned expulsion.

Critics at home and in the Jewish American community had called the government’s deportation plans unethical and a stain on Israel’s image as a refuge for Jewish migrants.

Before Monday’s announcement, the government had remained steadfast, bristling at what it considered cynical comparisons to the plight of Jewish refugees during World War II.

Over the years, Israel threatened the migrants with prison, placed them in a now-shuttered desert detention camp and tried to persuade them to leave by offering them money and a one-way ticket to Africa. After those options failed, it announced plans to begin deporting them to an unidentified African country — believed to be Rwanda or Uganda — on April 1.

Netanyahu said the plan was scrapped after it became clear that the “third country,” which he again did not identify, could not handle the influx.

“From the moment in the past few weeks that it became clear that the third country as an option doesn’t exist, we basically entered a trap where all of them would remain,” he said.

He described Monday’s compromise as the best available option.

In his Facebook post announcing the deal’s suspension, Netanyahu accused the New Israel Fund, a liberal advocacy group, and “elements” in the European Union of derailing a deal with Rwanda.

Migrants who earlier agreed to return to Africa had reported abuses and broken promises after arriving in Rwanda. In some cases, their travel papers were confiscated or they were quickly sent to Uganda. Both Rwanda and Uganda denied having any agreement with Israel.

Meir Ben-Shabbat, Netanyahu’s national security adviser, said the UN plan would be carried out in three phases over five years.

In all, the United Nations would resettle about 16,250 people, while Israel would absorb the same number. “A committee will be formed in order to identify them and find agreed solutions,” Ben-Shabbat said.

Shlomo Mor-Yosef, a senior official at Israel’s Interior Ministry, said migrants would be taken in throughout the European Union as well as in Canada and the United States.

Italy and Germany, two countries identified by Netanyahu as likely destinations, both denied having any agreement in place.

Canadian officials said they were in touch with Israel about the matter. Mathieu Genest, a spokesman for Canada’s immigration minister, said his government was reviewing over 1,800 requests by Eritreans to resettle in Canada. He noted that Canada has pledged to resettle a total of 4,000 Eritrean refugees by the end of the year.

As part of the framework, Israel said it would rehabilitate and develop affected neighbourhoods in south Tel Aviv, while also resettling African migrants elsewhere in the country.

The UN refugee agency said it signed a framework of common understanding “to promote solutions for thousands of Eritreans and Sudanese living in Israel.” The UNHCR said it would work to relocate about 16,000 Sudanese and Eritrean nationals and that others would receive “suitable legal status in Israel.”

Monim Haroon, a 28-year-old university student in Jerusalem who fled Darfur five years ago, expressed relief after the deal was announced.

“As asylum seekers we don’t care where we are going to be as long as it is a safe place, and these countries are willing to protect us and we can live with human dignity,” he said.

In a joint statement, a group of Israeli rights organizations praised Monday’s agreement and vowed to monitor it to make sure it was respected.

“We are extremely happy for the refugees,” said Sigal Rozen, of the Hotline for Refugees and Migrants. “We really hope that the Israeli government will stop abusing them and will respect their rights as refugees.”

Mark Hetfield, president of HIAS, a Jewish non-profit in the U.S. that protects refugees, praised the deal as “responsible” and “consistent with Jewish values.” He said the group would work with Israel and resettlement countries to aid the migrants.

“The timing of this announcement, during Passover, could not have been more appropriate as these asylum seekers, like our ancestors, all crossed the Sinai in search of freedom,” he said.

Not everyone was pleased. Cabinet Minister Naftali Bennett, leader of the nationalist Jewish Home party, said the deal turned Israel into a “paradise for infiltrators.” He called for the plan to be brought to the Cabinet for a vote.