Israel is to resettle thousands of African migrants in Western countries instead of forcibly deporting them, the Israeli government has said.

The country’s prime minister Benjamin Netanyahu said he had reached an “unprecedented understanding” with the UN Refugee Agency in which Israel will send more than 16,000 migrants to various Western countries willing to absorb them, while the same number of people will be granted official status in Israel.

Speaking on live television, he said: “This is a unique agreement between the UN commissioner and the state of Israel, that takes 16,250 people out, takes them out to developed countries like Canada, or Germany and Italy. That is the commitment the UN High Commissioner [for Refugees] has made – to organise it and even to fund it.

“The joint commitment is that, ‘You take out 16,250 and we will leave 16,250 as temporary residents’. That enables the departure of a very large number of people, 6,000 in the first 18 months.”

The new deal, which lifts the threat of forced expulsion to an unnamed African destination, is set to be implemented over five years.

In early January, the government said it would purchase tickets, obtain travel documents, and give each migrant $3,500 (£2,500) to leave – threatening them with arrest if they are caught still in the country after the end of March.

This followed years of violence, harassment and arrests that Africans have faced in Israel, with state officials calling them “infiltrators”, a “cancer to society”, and economic migrants in search of opportunities.

The expulsion had drawn protests and criticism from the UN, human rights agencies and academics, who warned Mr Netanyahu of “incalculable damage” to Israel’s reputation. There have been demonstrations in Tel Aviv attracting thousands of Israelis in support of the asylum seekers.

Human rights groups advocating on behalf of the migrants challenged the deportation plan in Israel’s High Court, arguing that for many of them their expulsion, even to a different country in Africa, would endanger them.