All perfect praise be to Allaah, the Lord of the Worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
Scholars have stated the reasons that entail detention. Imaam Al-Qarafi counted eight reasons:
1) The perpetrator should be held in detention if the Wali (i.e. guardian) of the wronged party is absent. This procedure is meant to guard the person who should be subjected to Qisas (i.e. retaliatory punishment) until the Wali comes back.
2) A fleeing slave should be held in detention for a year so as to preserve the owner's wealth, hoping that his owner will be identified.
3) A person who abstains from giving people their due rights should be held in detention so as to force him to give back people's due rights.
4) The perpetrator may be held in detention as Ta‘zeer (i.e. discretionary punishment) and deterrence from disobeying Allaah, the Exalted.
5) A debtor whose financial status is undetermined in terms of insolvency or solvency should be held in detention until he is proven solvent or insolvent so as to issue a grounded judgment.
6) A person who abstains from carrying out obligations that can only be carried out by him as long as he is still alive (and it is impermissible for any other person to carry them out on his behalf). For example, if a disbeliever embraces Islam while married to two sisters, more than four wives, or a woman and her daughter and abstains from divorcing those who are no longer lawful to him since he is now a Muslim.
7) A person who confesses that he owes another person a particular thing but abstains from identifying it. He should be held in detention until he identifies that thing or locates it; for example, he may say, 'it is this garment'.
8) A person who does not fulfill the rights of Allaah, the Exalted, that can only be fulfilled by him as long as he is still alive (and it is impermissible for any other person to fulfill them on his behalf), such as prayer and fasting. This is according to the Shaafi‘i and Maaliki scholars' opinion.
9) Some scholars mentioned another case that requires detention. That is the detention of the person who is the subject of a litigation. For example, if two men claimed to have married the same woman, she should be held in detention in the house of a righteous woman or in the judge's jail until the case is verified.
Allaah Knows best.