A teenage boy who continued to be held in federal detention centers years after an immigration judge determined that he did not have to be deported will be returned to his mother under a ruling Tuesday by a federal judge in Alexandria.

Judge James C. Cacheris of the Eastern District of Virginia chastised federal officials for depriving the boy’s mother, Dora Beltrán, of a chance to make her case to get back her son after he ran away from their Texas home at the age of 14 and was detained by U.S. Border Patrol agents in December 2013.

Now nearly 18, he was held at centers in five states, including Virginia, as his mother fought to bring him home.

Cacheris found that the Office of Refugee Resettlement did not offer due process to Dora Beltrán to challenge federal officials who continued to hold her son after they raised questions about her ability to supervise him and keep him safe.

“What care best suits the well-being of a child has not been, and likely cannot be, reduced to a formula capable of producing a ready answer,” Cacheris wrote in his decision finding that the teenager should be released. “That ORR undertook to make such a subjective judgment without any form of hearing . . . deprived [Beltrán] of a meaningful opportunity to present her case.”

Dora Beltrán’s teenage son has been ordered released after years of being held in detention centers. A judge Tuesday said she should have been given a hearing to try to get her son home. (N/A/Family Photo)

Because state courts generally handle child-custody cases and because the boy is soon to be an adult, Cacheris opted to order his release rather than set a new hearing on Beltrán’s challenge to the federal detention.

As a minor, the boy was identified in court papers only by his initials. Since he was first picked up and deemed an unaccompanied minor, he has been shuttled to detention centers and his mother has seen him only once.

Cacheris called the process that ORR officials used to deny Beltrán custody “opaque.” A home study that recommended separation, he added, did so “in spite of, rather than due to, her capacity as a parent.” She was given one opportunity to ask for reconsideration, which also was denied with only the briefest explanation that her son needed more structure than she could provide.

Mark Weber, a spokesman for the Department of Health and Human Services, said Tuesday that the office is reviewing the judge’s order.

“We are gratified that the court recognized long-standing constitutional law that the government simply cannot interfere with the parent child relationship without due process,” said Beltrán’s attorney, Susan Watson.

She said both mother and son are “exceedingly happy.” Knowing the decision was coming, she said, Beltrán had been too nervous to buy a turkey or plan on a Thanksgiving dinner. It is unclear whether her son, who is still in custody in California, will make it home in time for the holiday.

Beltrán and her family came to the border town of Rio Bravo, Tex., from Guatemala in 2005. Her son fell in with members of a drug cartel, who he said in a court filing pretended to befriend him. He was arrested for theft and assault, among other crimes, and was addicted to drugs, he said in a lengthy court filing.

Beltrán moved the family to Corpus Christi in 2013 in hopes of getting her son out of trouble. But he said that he ran back to Rio Bravo a few months later out of desperate addiction to heroin.

Officials say the teen is the only minor being held in ORR custody despite having had his immigration proceedings terminated and a parent legally in the country who wants him back. Cacheris stressed the rarity of the situation in his decision, and he said it “rings particularly hollow” for ORR to have claimed the office would confront an administrative nightmare if it had to offer parents additional hearings.

However, the judge also argued that the boy’s immigration status was immaterial. He deemed the ORR to be holding the teenager in “child welfare” custody, not immigration custody. That distinction is significant, because it means his ruling could be influential in cases involving minors who are at risk of deportation.