Every day, hundreds of illegal foreign workers, mostly South Asians, queue in the scorching heat outside an immigration office in the Saudi capital seeking to benefit from an amnesty to get their papers in order or leave.
Earlier this year, the oil-rich kingdom warned that illegal foreign workers risk being slapped with prison sentences and fines after a three-month grace period runs out on July 3.
Saudi Arabia also urged those whose residency permits have expired and those who are sponsored by someone other than their actual employers, in violation of the kingdom's labour laws, to take advantage of the amnesty without penalty.
Tens of thousands of foreigners working illegally in Saudi Arabia or who do not have the right local sponsor are affected.
With the clock ticking and the threat of mass deportations looming, they are desperately trying to regularise their situation.
More than 200,000 people, mostly Asians, have been expelled so far this year due to the new restrictions, immigration officials said.
In Saudi Arabia, like most of the Gulf states, foreigners need to be sponsored by a local business to get entry and work permits.
The practice of sponsoring expatriates has become a lucrative business for many Saudis who sell their sponsorship to foreigners desperate to enter for work.
According to official statistics, eight million expatriates work in the kingdom. Economists say there are another two million unregistered foreign workers.
Saudi Arabia, the world's largest oil exporter, is a goldmine for millions of people from poor Asian and Arab countries that are reeling under high levels of unemployment.
Ibrahim, an Egyptian, is among those now forced to leave a four-year job in the construction sector and return home because his work permit has expired.
"I arrived here at four o'clock this morning and I'm still waiting for my turn to obtain an exit permit," said Ibrahim, as he lined up with some 100 other illegal workers outside the immigration office.
His face is drenched in sweat and he is constantly wiping it away.
Ibrahim hopes he will obtain the document that allows him to leave Saudi Arabia without having to pay any penalty or serve jail time.
He also hopes he will be able to return to the oil-rich kingdom because he says, "the situation in Egypt is very bad."
The workers have been given a grace period until July 3 to get their affairs in order but many fear that they will miss the deadline because of the long wait outside the immigration office.
"I've been standing in line since 6:00 am to obtain the exit permit," said Abdul Azim Shahid, from Bangladesh, who began to lose hope his turn would arrive as the centre's closing time approached.
The 28-year-old has been working in the kingdom for eight years.
"For the first two years I worked as a salesman to make up for the residency" fees payable to his Saudi sponsor, he said.
Mozafar Suleiman, an elderly Indian who works in transportation, hopes to return to Saudi Arabia like Ibrahim and Shahid, but complains of "abuse" of foreign workers in the kingdom.
"Things might improve with the new residency rules," he said.
Long queues have also been seen outside the embassies of India, Bangladesh, Indonesia and the Philippines as foreign workers queue to renew expired passports.
The new regulations introduced by the labour ministry aim to reduce the number of foreign workers to create jobs for millions of unemployed Saudis.
Although the kingdom has the largest Arab economy, the unemployment rate among Saudis is above 12.5 percent.
Saudi Arabia has warned employers who shelter illegal workers that they will be liable to up to two years in prison if they do not toe the line.
Bangladeshis, Indians, Pakistanis and Yemenis, who work in low-paid jobs across the kingdom, will be worst affected.
Labour Minister Adel Fakih has admitted that "six million foreign workers are employed in menial jobs unfit for Saudis and 68 percent of them are paid less than 1,000 riyals ($270) per month."
The majority of Saudis prefer working in the public sector where they are better paid for shorter working hours and enjoy more holidays.