Israel says it has reached an agreement with the United Nations to scrap plans to deport African asylum seekers and will resettle many in Western countries instead.

Prime Minister Benjamin Netanyahu’s office said it has 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.

The deal lifts the threat of forced expulsion to an unnamed African destination.

Israel considers the vast majority of the nearly 40,000 migrants to be job seekers and has said it has no legal obligation to keep them.

Critics have called the deportation plan unethical and a stain on Israel’s image as a refuge for Jewish migrants.

Israel said the new deal will be implemented over five years.