Nigerian police say they have rescued nearly 500 men and boys from a building in the northern city of Kaduna, where the detainees were allegedly tortured.
Those held at the building, which housed an Islamic school, included a large number of children and some were found chained up, police said.
Kaduna police chief Ali Janga told the BBC the building was raided after a tip-off about suspicious activity.
He described it as a “house of torture” and a place of human slavery.
Some captives were as young as five, police said.
The detainees, not all Nigerian, said they had been tortured, sexually abused, starved and prevented from leaving – in some cases for several years.
It was not clear how they got there. Some of the children told police that their relatives had taken them there, believing the building to be a Koranic school.
Two of the children freed by police said their parents had sent them there from Burkina Faso. Police believe the rest are mostly from northern Nigeria.
Eight suspects, most of them teachers, were arrested. The police chief said the detainees – some with injuries and starved of food – were overjoyed to be freed.
They were taken to a stadium in Kaduna overnight to be cared for while arrangements were made to find their families. Nigerian authorities said the nearly 500 freed captives would be given medical and psychological examinations.
Islamic schools are popular in northern Nigeria but there have long been allegations of abuse in some schools, and of pupils being made to beg for money on the streets.