WASHINGTON (AP) — A divided Supreme Court ruled Tuesday against a group of immigrants in a case about the government’s power to detain them after they’ve committed crimes but finished their sentences.

The issue in the case before the justices had to do with the detention of noncitizens who have committed a broad range of crimes that make them deportable. Immigration law tells the government it must arrest those people when they are released from custody and then hold them while an immigration court decides whether they should be deported.

But those affected by the law aren’t always picked up immediately and are sometimes not detained until years later. In the case before the Supreme Court, a group of mostly green card holders argued that unless they’re picked up essentially within a day of being released, they should be entitled to a hearing where they can argue that they aren’t a danger to the community and are not likely to flee. If a judge were to agree, they would not have to remain in custody while their deportation case goes forward. That’s the same hearing rule that applies to other noncitizens the government is trying to deport.

But the Supreme Court disagreed with the immigrants’ interpretation of federal law in a 5-4 ruling that divided the court along ideological lines. Looking at a statutory provision enacted by Congress in 1996, Justice Samuel Alito wrote that “neither the statute’s text nor its structure” supported the immigrants’ argument. The court’s conservative justices sided with the Trump administration. The administration argued, as the Obama administration did, that those affected by the law aren’t entitled to a hearing where they can argue for their release, regardless of whether they are arrested immediately after being released from custody or not.

Department of Justice spokeswoman Kerri Kupec said the administration was “pleased with the decision.”

Justice Stephen Breyer, in a dissent he read aloud in court, said that the larger importance of the case has to do with the power his colleagues’ ruling gives the government.

“It is a power to detain persons who have committed a minor crime many years before. And it is a power to hold those persons, perhaps for many months, without any opportunity to obtain bail,” Breyer said.

He wrote that in his view the law requires immigrants who have committed crimes to be detained “within a reasonable time after their release” from custody, “presumptively no more than six months.” If the person is not detained within that time, they should get a hearing where they can argue for their release, Breyer wrote.

The American Civil Liberties Union represented the immigrants in the case before the Supreme Court. ACLU attorney Cecillia Wang, who argued the case, said after the decision that the ACLU will call on Congress to clarify the law and will continue to pursue options in court.

Tuesday’s ruling was based on the text of the statute, and Wang said the ACLU will argue that the statute, as interpreted by the justices, is unconstitutional. Wang also called the decision an “extreme waste of taxpayer money,” saying it locks up individuals who are not a danger to the community.

The case before the justices involved a class-action lawsuit brought by noncitizens in California and a similar class-action lawsuit brought in the state of Washington. In those cases, the U.S. Court of Appeals for the 9th Circuit sided with the immigrants, but other appeals courts had sided with the government in similar cases.

One of the lead plaintiffs involved in the California case, Mony Preap, has been a lawful permanent resident of the United States since 1981 and has two convictions for possession of marijuana. He was released from prison in 2006 but was not taken into immigration custody until 2013. Preap has since won his deportation case, allowing him to remain in the country.

The case is 16-1363 Nielsen v. Preap.

___

Follow Jessica Gresko on Twitter at http://twitter.com/jessicagresko