The migrants were rounded up during a huge crackdown in the Tripoli region during which telecommunications equipment was also seized, the official told AFP.
Hundreds of those who had been rounded up were seen sitting on the ground outside a detention centre in Tripoli, as authorities distributed food and drink.
Libya has a coastline of 1,770 kilometres (more than 1,000 miles) and has long been a stepping stone for Africans seeking a better life in Europe.
Most head for the Italian island of Lampedusa which lies some 300 kilometres (185 miles) from Libyan shores.
More From This Section
Libya has now two governments and parliaments vying for power and armed militias battling for its oil wealth.
The Tripoli government, which is not recognised by the international community, has stepped up in recent weeks arrests of illegal migrants.
Last Sunday, officials linked to the Tripoli government announced the arrest of 400 illegal migrants on the same day of the launch of an operation targeting people smugglers.