Illegal foreign workers in Saudi Arabia, mostly Asians, are in a race against time to take advantage of an amnesty ending Wednesday that would allow them to stay or return home without prosecution.
King Abdullah announced the amnesty on April 3, granting foreign workers three months to regularise their residency or leave the oil-rich Gulf monarchy to avoid being blacklisted or jailed and fined.
More than 1.5 million illegal foreign workers came forward during the first two months of the amnesty, the labour ministry said.
It did not say how many illegal foreign workers currently live in the kingdom, but the number is reported to be around two million.
Of these, some 180,000 have left in addition to more than 200,000 unregistered workers expelled at the start of the year under new regulations to stamp out illegal immigration.
Many workers are still queueing outside their embassies to obtain documents to either leave Saudi Arabia or legalise their status before Wednesday.
As in most Gulf states, foreigners in Saudi Arabia need to be sponsored by a local business to obtain entry and work permits.
Foreigners desperate to work in the country are willing to pay for sponsorship, and sponsoring expatriates has become a lucrative business for some Saudis.
But under the new rules workers can be employed only by their own sponsors.
Sharon, a Filipina maid, stood queing in the scorching heat outside her country's embassy in Riyadh.
"I'm trying to renew my passport as I am desperate to find an employer to sponsor me and keep me in the kingdom," she said.
"I've provided fingerprints and obtained a travel document, in case I don't get my passport ready in time," the 38-year-old said.
But 25-year-old Anne, also from the Philippines, was concerned.
"I have a travel document in hand, but I cannot find a seat on a flight to Manila. I am anxious to be with my daughter who I haven't seen in four years and hold her in my arms," she told AFP.
In Jeddah, the commercial capital, Indonesian worker Ali Rahman stood outside Jakarta's consulate, desperately waiting to finalise his documents.
"I've lost hope unless the amnesty is extended to after July 3," he said.
"There are still hundreds of us waiting here for consular formalities. And once completed, the paperwork has to go to the immigration authorities and the labour ministry."
It is a worrying time for the workers, most of whom are from India, Bangladesh, Pakistan and Indonesia, but with some from Yemen and Egypt too.
They are fearful of the campaign of arrests promised by authorities once the amnesty expires.
Saudi Arabia, the world's largest oil exporter, is a goldmine for millions of people from poor Asian and Arab countries where unemployment is high.
According to official statistics, eight million expatriates work in the kingdom.
The new labour ministry regulations aim to reduce the number of foreign workers to create jobs for millions of unemployed Saudis.
Although the country has the largest Arab economy, its unemployment rate is above 12.5 percent.
Saudi Arabia has warned employers who continue to shelter illegal workers that they risk up to two years in prison.
Economic analyst Fadhl al-Bouainain said the move will benefit both Saudis and foreign workers.
"This will help reorganise the labour market to promote the work of Saudis and protect foreign workers from the abuse of sponsors," he said.
However, he warned that the massive departure of tens of thousands of workers will "negatively impact business", pointing out that some sectors, including construction, "are not attractive for Saudis" who want better paid positions.
He said the labour ministry should reduce by "at least 30 percent the number of workers in the kingdom, if the campaign is to be successful".
Another expert, Abdulwahab Abu Dahesh, was more sceptical of the amnesty's touted benefits.
"As foreigners do more low-paid jobs, replacing them with Saudis will not be quick and the impact on the national economy will take some time."