Children who immigrate to the U.S. illegally alone must be given a court hearing before being detained, a federal appeals court ruled Wednesday.

A three-judge panel of the 9th Circuit Court of Appeals said unanimously that unaccompanied minors, as children who migrate illegally are known, are entitled to bond hearings that determine whether they can be released until their case is heard in court.

The judges said the federal government must follow the terms of a 1997 lawsuit settlement that required bond hearings for minors.

After that settlement, Congress passed two laws dealing with unaccompanied minors, including a 2002 law transferring responsibility for children who travel alone illegally to the Department of Health and Human Services until their court cases are heard.

Once in the custody of HHS, minors are typically detained for a brief period before being permitted to join relatives or other sponsors in the interior of the country, until they have to appear in court.

Government lawyers argued those statutes overruled the 1997 settlement, but the appeals court disagreed. The government may appeal the decision to a full panel of the 9th Circuit, or to the Supreme Court.

"In the absence of such hearings, these children are held in bureaucratic limbo, left to rely upon the [government's] alleged benevolence and opaque decision making," Judge Stephen Reinhardt, an appointee of former President Jimmy Carter, a Democrat, wrote for the court.

Three years ago, a flood of unaccompanied children, mostly fleeing violence and poverty in Central America, traveled illegally to the U.S, in what the government described as a crisis.

Since President Trump took office, border crossings have dropped dramatically, as the administration has adopted stricter standards for who it targets for deportation.