Israel announced on Monday it had reached a deal with the UN refugee agency to cancel a controversial plan to deport African migrants and replace it with a new one that will see thousands sent to Western countries.
The deal means thousands more of the primarily Sudanese and Eritrean migrants will remain in Israel at least temporarily.
It also ends the possibility that many would be forcibly deported to an unnamed African country, widely believed to be Uganda or Rwanda.
A minimum of 16 250 migrants will be resettled in Western nations including Canada, Germany and Italy under the agreement, according to Prime Minister Benjamin Netanyahu.
"The agreement stipulates that for each migrant who leaves the country, we commit to give temporary residence status to another," Netanyahu said in a televised address after Israel announced the deal.
Germany and Italy, however, said they were unaware of any such resettlement deal for African migrants from Israel, although the German interior ministry said Berlin always respected its humanitarian commitments.
Netanyahu in January announced the implementation of a programme to remove migrants who entered illegally, giving them a choice between leaving voluntarily or facing indefinite imprisonment with eventual forced expulsion.
According to interior ministry figures, there are currently some 42 000 African migrants in Israel, half of them children, women or men with families, who were not facing immediate deportation.
As the migrants could face danger or imprisonment if returned to their homelands, Israel offered to relocate them to an unnamed African country, which deportees and aid workers said was Rwanda or Uganda.
They had initially been given a deadline of April 1, but Israel's supreme court suspended the plan on March 15 while it continued to examine it.
Israel's statement announcing the new plan on Monday said there was no longer a need to send migrants to unnamed third countries.
Netanyahu said in his remarks on Monday that he had to abandon the earlier plan because the option of sending them to a third country "no longer exists".
Rwanda and Uganda have said they would not accept those deported against their will.
The earlier plans had drawn sharp criticism from the United Nations refugee agency as well as from some Israelis and rights activists.
The migrants' presence in Israel has become a political issue, with Netanyahu referring to them as "not refugees but illegal infiltrators".
Religious and conservative politicians have portrayed the presence of Muslim and Christian Africans as a threat to Israel's Jewish character.
A group of residents of southern Tel Aviv, where many of the migrants have settled, immediately denounced the new plan in a statement, calling it "a shame for the state of Israel."
Under the new five-year plan, Israel will "regulate" the status of those not being resettled - signalling they will be allowed to stay at least temporarily.
Migrants began entering Israel through what was then a porous Egyptian border in 2007. The border has since been strengthened, all but ending illegal crossings.
Holot, an open facility where inmates were free to leave during the day but had to return at night, was opened in 2013 with the aim of siphoning migrants away from the cities.
The facility was closed last month as part of the previous plan.
Some Holot inmates were transferred to the nearby Saharonim prison. Others who had submitted asylum requests before January 1 were released pending a decision.
Another 300 had been freed after agreeing to leave Israel, according to Israel's immigration authority.
Those released were barred from living or working in seven cities with high migrant populations, including Tel Aviv, Jerusalem and the Red Sea resort of Eilat.
Israeli officials had said that no one they classify as a refugee or asylum-seeker would be deported, though the process of granting asylum has been criticised as extremely slow and biased against claims.
Only a handful of asylum claims have been approved in recent years.
Those opposed to the original plan included Holocaust survivors who say the country has a special duty to protect migrants.