Israel has cancelled plans to deport migrants en masse to Africa after reaching a deal with the United Nations refugee agency.
More than 16,000 asylum seekers will instead be resettled in unspecified Western countries, Prime Minister Benjamin Netanyahu’s office said.
The rest, about 18,000 people according to Israeli media, will be given permanent residency in Israel.
Israel’s Supreme Court had blocked deportations meant to begin on Sunday.
The plan to send the migrants to African countries – reported to be Uganda and Rwanda – was condemned by Israeli activists and sparked protests.
The new plan will be implemented over a five-year period. Mr Netanyahu’s office described the agreement as “unprecedented”.
“These understandings will allow the removal of more migrants from Israel than in the previous plan, and under UN and the international community’s auspices,” a statement said.
Most of the Africans are from Eritrea – a one-party state whose leaders have been accused of crimes against humanity by a UN inquiry – and war-torn Sudan.
Read about Eritrea
More on Sudan
Israel’s unwanted African migrants
They say they fled danger at home and that it is not safe to return, but Israel considers the majority of the African asylum seekers affected by the policy to be economic migrants.
Most of them entered from Egypt several years ago, before a new fence was built along the desert border. This has ended most illegal crossings.
A note on terminology: The BBC uses the term migrant to refer to all people on the move who have yet to complete the legal process of claiming asylum. This group includes people fleeing war-torn countries such as Syria, who are likely to be granted refugee status, as well as people who are seeking jobs and better lives, who governments are likely to rule are economic migrants.