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 Tuesday.

In a 5-3 ruling Tuesday, with Justice Elena Kagan recusing, the court ruled that immigrants do not have the right to periodic bond hearings.

The ruling is a defeat for immigration advocates, who argued that immigrants should not be held for more than six months at a time without such a hearing.

ADVERTISEMENT

The Supreme Court ruling follows a Trump administration appeal of a ruling by the 9th Circuit Court of Appeals last year that imposed a rule requiring immigrants held in custody be given a bond hearing every six months, as long as they aren't considered a flight risk or a danger to national security.

“To impose a rigid six-month rule like the Court of Appeals did is really a mistake,” acting Solicitor General Ian Gershengorn said in November 2016.

In its ruling, the court affirmed the right of the government to detain immigrants while it determines whether they should be allowed in the country.

"Immigration officials are authorized to detain certain aliens in the course of immigration proceedings while they determine whether those aliens may be lawfully present in the country," Justice Samuel Alito wrote in the majority opinion.

The lead plaintiff in the class-action lawsuit, Alejandro Rodriguez, is an immigrant with permanent legal status who was convicted of possession of a controlled substance and joyriding. He was detained by immigration officials for three years without a bond hearing.

The ACLU took up his case, eventually winning his release and the cancellation of his deportation order. The government's appeal was begun under the Obama administration, and continued after President Trump Donald John TrumpBiden leads Trump by 36 points nationally among Latinos: poll Trump dismisses climate change role in fires, says Newsom needs to manage forest better Jimmy Kimmel hits Trump for rallies while hosting Emmy Awards MORE took office last year.