Israel has cancelled its plan to deport thousands of African migrants to their home countries and will instead transfer them to third-party nations in the West, according to Israeli officials.

Under an agreement with the United Nations High Commissioner for Refugees, Israel will “facilitate transfer” of roughly 16,000 illegal African immigrants to Western countries, in return for a guarantee to “formalize the status” of those who remain, reports the Times of Israel. Canada is expected to be a primary recipient of the migrants.

“Israel has reached an unprecedented joint understanding with the United Nations commissioner for refugees to remove migrants from Israel,” Prime Minister Benjamin Netanyahu’s office said in a statement.

Before Israel completed a barrier along its border with Egypt in 2013, about 60,000 African migrants — mostly from Sudan and Eritrea — crossed the desert frontier and settled in the Tel Aviv area. Many of the illegal immigrants say they fled violence and persecution, but Israel treats them as economic migrants.

About 38,000 African migrants are still living illegally in Israel as of this year, immigration officials say. Israel has granted asylum to fewer than 1 percent of those who have applied, with the aim of getting most of the migrants to return to their home countries.

Last year, Israel developed a repatriation plan that gave the Africans two options: leave voluntarily or be sent to prison. The plan involved offering the migrants $3,500 payments and free airline tickets to return home or to “third countries” such as Rwanda and Uganda. Any illegal immigrants who did not have pending asylum claims were to be deported beginning in April.

Israel’s deal with UNHCR now rescinds that proposal in favor of a new plan that will be implemented in three phases over five years, the prime minister’s office says, according to Haaretz. The African migrants will be granted permission to work in Israel until they leave, while those who remain will be be put on a path to residency status.

Additionally, the government will “encourage a more balanced geographic distribution of the populations who will remain in Israel, while providing vocational advising and professional training,” the prime minister’s office said.

ALSO WATCH: Media blames Trump for Facebook data use, but praised Obama and Hillary

The new migrant agreement is a sharp turnabout for Netanyahu’s right-wing government, which has characterized the resettlement of African migrants in Israel as harmful to the country’s Jewish character and social cohesion. The original deportation plan had to be canceled “because of legal considerations and diplomatic difficulties on behalf of third-party countries,” Netanyahu’s office said.

Two of those countries, Uganda and Rwanda, refused to accept the African asylum seekers once they learned Israel intended to deport them by force, reports Haaretz.

Follow Will on Twitter

Send tips to will@dailycallernewsfoundation.org.

Content created by The Daily Caller News Foundation is available without charge to any eligible news publisher that can provide a large audience. For licensing opportunities of our original content, please contact licensing@dailycallernewsfoundation.org.