The directive is meant to ensure that the “elections are free, fair and devoid of anomalies”, the Nigeria Immigration Service said.
Border officials have been told to ensure strict enforcement of the order.
The presidential and parliamentary elections are reported to be the most tightly contested since military rule ended in 1999.
The immigration service said it had seized 6,000 voters cards and other Nigerian identification documents from illegal immigrants in the run-up to the elections.
President Muhammadu Buhari had earlier on Thursday urged security agencies to be “firm and courageous” in the election period, and warned against riots after the announcement of election results.