The Court found that the detention of aliens pending deportation is acceptable only in order to enable States to prevent unlawful immigration while complying with their international obligations, particularly under the 1951 Geneva Convention Relating to the Status of Refugees and the ECHR. Such holding should not be prolonged excessively, otherwise there would be a risk of it turning a mere restriction on liberty into a deprivation of liberty. In that connection account should be taken of the fact that the measure is applicable not to those who have committed criminal offences but to aliens who, often fearing for their lives, have fled from their own country.
Source: official link