Foreigners living and working in the country without official work permits have 60 days to get documentation or risk being arrested.
Interior Cabinet Secretary Fred Matiang'i on Monday said the step will help the government get rid of tax evaders and criminals.
"These statistics and figures do not appear to be realistic, as there seems to be more than 34,000 registered foreigners, probably more than 100,000," Dr Matiang'i said at Nyayo House in Nairobi when setting the activity in motion.
He said the Immigration department will embark on creating a digital register of legal foreign workers, and provide them with electronic identification cards.
"The country spends up to Sh360 million annually on deportation of illegal immigrants; money which should be put into other important uses.
"After the 60 days, if you do not have the legal work documents you will be arrested and locked up. From therein you will have to find your own means of coming up with the amount needed to get back to your country," he warned.
"The country loses a lot due to unpaid taxes, job opportunities going to illegal foreigners at the expense of citizens, terrorists capitalising on this loophole to carry out their atrocious activities in the country, and expenses incurred in deportation," he noted.
At the same time, Dr Matiang'i put on notice immigration officials issuing work permits and other documentation illegally.
"The monkey business era in this department must come to an end. For every work permit issued, we will keep a digital trail of the records and specific officials involved in issuing them to identify who issued a permit," he said.