WORTHINGTON, Minn. (AP) -- A judge in southern Minnesota says the Nobles County Sheriff's Office can't keep jail inmates in custody for immigration officials after those inmates are eligible for release in state cases.

Thursday's ruling comes in a class-action lawsuit filed by the American Civil Liberties Union of Minnesota.

The ACLU argued that the sheriff's office routinely violated the rights of jail inmates by transferring them from local to federal custody at the request of U.S. Immigration and Customs Enforcement.

Minnesota Judge Gregory Anderson agreed.

The sheriff did not immediately return messages seeking comment.