Pakistani police rescued 45 students found chained in the basement during a raid late Monday on an Islamic seminary in the southern port city of Karachi, police said.
Officers also arrested two clerics at the Madrassa Zakarya in Karachi's central Sohrab Goth area but the head of the seminary managed to escape, police official Mukhtiar Khaskheli told AFP.
"At least 18 of those chained are aged 20 or younger, while the rest are older," Khaskheli said.
Some Islamic schools in Pakistan are accused of training militants and supporting violent extremist groups, with some dispatching fighters to neighbouring Afghanistan.
"The madrassa officials claim that they had chained those students because they were drug addicts and they wanted to rehabilitate them and make them better Muslims," the police official said.
Khaskheli said a full scale investigation had been started which would also inquire about any possible links with militants.
"Every possibility including its involvement in militancy will be investigated upon," said Sharfuddin Memon, a spokesman for the home department of Sindh province, of which Karachi is the capital.
Memon said the incident highlighted the brutality in society.
"It showed the brutalised aspect of our society and our police's effort was aimed at eradicating that element," he said.
Local private Samaa TV showed footage of the madrassa and the chained students, who danced in jubilation as police started to release them.
According to government records, there are at least 15,148 seminaries in Pakistan with more than two million students -- around five percent of the 34 million children in formal education.
But officials suspect thousands more go unregistered, providing sons of Pakistan's poverty-stricken majority the only education they can afford.