Immigrants held by the U.S. government and facing deportation are not entitled to a bond hearing, even after months or years of detention, said the United States Supreme Court Tuesday.

“Immigrants can be held by U.S. immigration officials indefinitely without receiving bond hearings, even if they have permanent legal status or are seeking asylum,” the Supreme Court ruled today.

The Supreme Court overturned a ruling for a case originally brought by the American Civil Liberties Union (ACLU) that had guaranteed periodic bond hearings, and the possibility of release, for thousands of foreigners who are being detained while facing deportation.

The justices, voting 5-3, said federal law doesn’t require those hearings. Justices Stephen Breyer, Ruth Bader Ginsburg and Sonia Sotomayor dissented. Justice Elena Kagan did not take part in the ruling because she was briefly involved in the litigation when she served as U.S. solicitor general under President Barack Obama.

The ACLU had previously said that about 34,000 immigrants are being detained on any given day in the U.S. and that cases are resolved within six months.