Police say children as young as five were among those released from the building in Kaduna
More than 300 captives, many of them children, have been rescued in the northern Nigerian city of Kaduna.
The children aged young as five were found in a building that was thought to be an Islamic school.
Police said they had been tortured, starved and sexually abused. Some of them were chained up.
''This place is neither a rehab or an Islamic school because you can see it for yourselves," Ali Janga, police commissioner for Kaduna state, told reporters outside the building.
He said there were many small children and that some had been brought from neighbouring countries including Burkina Faso, Mali and Ghana.
"They were used, dehumanized, you can see it yourself," he said.
Pictures of Thursday's raid were shown on local television in Nigeria.
Police said seven teachers from the school had been arrested, while the children are being housed at a nearby stadium as the authorities try to trace their parents.
Islamic schools, known as Almajiris, are common across the mostly Muslim north of the country.
Nigeria's population is half Christian, half Muslim.
Many parents in the north, which is the poorest part of a country, choose to leave their children to board at such schools. Most adults live on less than $2 a day.
Earlier this year, the government of President Muhammadu Buhari said it planned to eventually ban the schools, although it would not happen immediately.