Algeria plans to grant residency rights and job permits to illegal African migrants amid a shortage of workers in farming and construction and after a surge in racist sentiment across the country.
Prime Minister Abdelmadjid Tebboune's plan follows the launch of an anonymous online campaign that blames African migrants for taking jobs and spreading the HIV virus that causes Aids.
To determine the number of beneficiaries of the scheme, the interior ministry is organising a census while security services will screen potential residency candidates.
"They will get a residency document which will allow them to get a job," Tebboune told politicians on Friday night.
He gave no further details on the scheme.
"That's great news, I will be happy if I can work under the framework of the law," a young Malian working illegally in a housing project as a mason in Ouled Fayet, west of Algiers, told Reuters news agency.
Youth unemployment is running at around 30 percent in Algeria, but the country also faces a shortfall of workers in some sectors as it tries to steer its economy away from overreliance on oil and gas production.
The online anti-migrant campaign has shocked many in Algeria, which sees itself as a leading influence in the Sahel region and more widely in Africa, for example negotiating a peace deal in 2015 in Mali.
Last month a hashtag "No to Africans in Algeria" was widely shared on Twitter and Facebook, calling for expulsions to protect Algerian families and prevent "chaos".
Amnesty International's local representative, Hassina Oussedik, has urged the government to do more to protect African migrants.
There are unofficially an estimated 100,000 African migrants in Algeria, who have escaped acute poverty and conflict back home.
Most of the migrants are from Mali, Niger and Burkina Faso and some use Algeria as a transit country en route to Europe via neighbouring Libya.