A New Jersey appeals court has ruled in a precedential decision that state courts cannot order criminally charged immigrants facing deportation to be detained in state custody to ensure that they are not removed from the country by federal immigration authorities before trial.

The Appellate Division's ruling, which examines the state bail reform law's interaction with federal immigration law, comes in the consolidated appeals of defendants Juan Molchor and Jose Rios, who were arrested and charged with second-degree assault after allegedly smashing bottles over an acquaintance's head at a party.

According to Appellate Division Judge Mitchel Ostrer's opinion Wednesday, the prosecution argued that the pair were a flight risk because of their undocumented status. Prosecutors also expressed concern that if they were taken into U.S. Immigration and Customs Enforcement custody, they could be deported without the "benefit of justice from having a fair trial."

The Gloucester County Law Division ordered their detention, reasoning it would ensure the appearance of the defendants at trial, over the objection of defense attorneys, who argued their clients did not pose a flight risk because of their lack of criminal history, according to the decision.

Appeals followed, and the defendants raised the issue of whether New Jersey's Criminal Justice Reform Act authorizes a court to detain undocumented immigrants after arrest in order to stop their potential removal by ICE and ensure they appear at trial.

"Construing the Act in light of its legislative history and persuasive federal authority, we conclude it does not," Ostrer wrote Wednesday, joined on the panel by Appellate Division Judges Carmen Messano and Ronald Susswein.

"Rather, the risk of a defendant's failure to appear justifying detention must arise from the defendant's own misconduct, not the independent acts of a separate arm of government that may prevent a defendant from appearing," Ostrer said.

He continued, "The trial court erred in detaining defendants in part out of concern that their possible removal from the country would prevent their appearance at trial. The trial court also lacked sufficient evidence for its finding that no conditions would reasonably assure that they would not obstruct justice, and, in Rios's case, would not pose a risk to the safety of others."

The court remanded the case for reconsideration, instructing the lower court to weigh the risk of the defendants' flight against their own potential for misconduct.

"We also vacate the court's findings, as lacking sufficient evidence in the record, that defendants posed an unmanageable risk that they would obstruct justice by retaliating against the alleged victim, or that Rios posed a risk of danger to others or the community," Ostrer said. "The court did not consider the efficacy of other possible conditions to reasonably assure that defendants would not obstruct the criminal justice process. Simply asserting that defendants resided within a five-minute drive from the alleged victim does not suffice by itself to support detention."

The New Jersey Public Defender's Office represents Rios. Tamar Lerer, assistant deputy public defender with the Appellate Section, stated: "We are very gratified by today's well-reasoned decision, which ensures that all New Jerseyans will be treated equally by New Jersey courts implementing the Criminal Justice Reform Act."

Cristina Vazquez, the attorney representing Molchor, couldn't be reached at numbers listed for her in the state judiciary's online attorney index.

A spokesman for the Gloucester County Prosecutor's Office, which is prosecuting each defendant's case, also couldn't be reached. Jonathan Amira, a special deputy attorney general and acting assistant prosecutor, argued for the state.