Thousands of illegal immigrants in Spain queued for legal papers as a three-month amnesty came to a close.
Some queued through the night to meet the amnesty deadline
The government says 700,000 people have registered for the right to live and work in Spain under the amnesty.
Spain argues that the measure helps manage immigration and ensures workers have legal protection and pay taxes.
But the amnesty has been opposed by some European Union countries who fear it will make Spain a gateway for more illegal immigrants.
Some 40,000 rushed to beat the 2100 (1900 GMT) deadline for the amnesty on Saturday, Labour Minister Jesus Caldera reportedly calculated.
Many had spent the night in the streets outside the 193 government offices across Spain that were processing the paperwork.
They have had to provide proof of residency in Spain for at least six months, a work contract of at least six months and no criminal record.
Mr Caldera said he believed around 700,000 had applied since the amnesty began on 7 February.
"Almost 700,000 jobs brought out of the black economy! That represents between 80% and 90% of all such jobs held by immigrants in Spain. We can feel very satisfied," he told reporters.
Ecuadoreans were the largest group to apply under the amnesty, followed by Romanians and Moroccans.
"If you get the papers, you go from being nobody to being somebody. You have a document with your name on it, you exist," Ecuadorean Alvaro Salgado, 30, said after queuing for seven hours for his papers in Madrid.
Some of those waiting in line had none of the required documents, but queued anyway.
"For the moment, there is no hope. They said without a work contract, there is no hope. I am waiting to know if there will be another possibility in the future," a 26-year-old Nigerian, who gave his name as Teddy, told Reuters news agency.