The Malaysian authorities are expected to launch a massive operation to arrest and deport illegal immigrants after an amnesty deadline expired.
Illegal immigrants who overstay face fines, whipping and jail
The deadline allowing undocumented foreigners to depart without penalty expired at midnight (1600 GMT).
Thousands of illegal immigrants queued at ports and airports, hoping to leave before the operation started.
Illegal workers are now liable to long jail terms, fines of thousands of dollars and whipping with a cane.
Thousands of police and civilian volunteers have been drafted into a campaign to round up foreigners without the right papers.
Officers will be inspecting building sites, plantations, factories, restaurants and even private homes with domestic servants to try to arrest them.
Illegal immigrants are widely blamed for rising crime. But human rights groups say the participation of so many civilians in the round-ups, some of them carrying firearms, could easily lead to accidents and abuses, says the BBC's Jonathan Kent in Kuala Lumpur.
Estimates have put the number of undocumented foreign workers in Malaysia at up to one-and-a-half million.
The scenes were much the same at exit points around Malaysia - foreign workers leaving, carrying their children and the few possessions they have managed to accumulate, our correspondent says.
Most of the illegal immigrants have come from neighbouring Indonesia, which has twice persuaded Malaysia to extend the expulsion deadline.
But although Indonesia's resources are still stretched coping with the tsunami devastation in Aceh, Malaysia has signalled that it will wait no longer.
The Malaysian government says the deportations will be conducted humanely and it has promised to process applications quickly from those who have left before the deadline and want to return.