Detention of a minor for a short period of time can't be used to argue against providing him citizenship that would have naturally occurred if he'd been living at home with his parents, the U.S. Court of Appeals for the Second Circuit ruled Thursday.

The panel, composed of Circuit Judges Dennis Jacobs, Peter Hall, and Christopher Droney, said a person held on support-for-terrorism charges he would later be found guilty of can't be denied his citizenship, even though he was in custody when his father became a citizen ahead of his 18th birthday. Despite the government's attempt to argue otherwise, the panel found that “a parent's physical custody of a child does not cease due to a child's brief, temporary separation from a parent.”

Agreeing that the Board of Immigration Appeals had the power to deny a person's citizenship because they were separated from family at a key moment in the naturalization process “would likely produce unfortunate consequences for the citizenship of other [legal permanent resident] children facing different situations,” the panel went on to find.

Seventeen-year-old Mohammed Khalid was arrested in Pennsylvania in July 2011 for allegedly conspiring to provide material support for terrorism. He was placed in pretrial juvenile detention. While there, Khalid's father became a U.S. citizen. Ultimately, Khalid would cooperate with prosecutors, testifying in grand juries in two separate investigations, earning himself a downward departure during his sentencing to five years, which he served. He's believed to be the youngest person ever prosecuted for terrorism.

After serving his sentence Khalid was transferred to the Department of Homeland Security, where Immigration and Customs Enforcement gained custody over him, and removal proceedings based on his conviction began. Most significantly, he moved to terminate the proceedings based on his own U.S. citizenship derived from his father's naturalization. An immigration judge denied the motion, because Khalid had been in the government's custody when his father was naturalized. The Board of Immigration Appeals upheld the IJ's ruling, finding that a child must physically reside with the citizen parent to satisfy the “physical custody” requirement under federal naturalization law.

On appeal, the parties argued two separate ways to interpret the “physical custody” requirement for citizenship. Khalid argued the term defines a legal relationship between parent and child, while the government countered that it was to be taken literally: absent actually residing with a citizen parent, a child cannot gain his or her own status.

The panel noted that family law has been left almost exclusively to the states. But the parties argued—convincingly, according to the panel—that there are different ways to interpret state law, while noting that state and federal law definitions of physical custody are “often at odds” with each other. The panel expressed unease at BIA's attempts to reduce physical custody to an “actual residency” requirement, which was rarely found in state law.

The panel was forced to turn to the statutory context of federal law, specifically the Child Citizenship Act of 2000, to find its answer. The bill, the panel found, showed Congress' intent to make derivative citizenship “more available to the children of married parents,” which ultimately further supported Khalid's arguments. The statutory history and context, while not resolving all the ambiguities attached to the “physical custody” issue, did show Congress intended to ensure a child's connection to the naturalized parent, which supported the appellant's position, the panel said.

“[T]he history of the derivative citizenship statute supports reading the statute—and the term 'physical custody,' in particular—to ensure that a child's 'real interests' are in the United States through a genuine connection between the United States citizen parent and that parent's child. Nothing in either the CCA's text or history suggests that Congress intended to abandon that requirement in enacting the CCA. Indeed, the physical custody provision demonstrates a desire to continue ensuring that purpose is met,” the panel stated.

Additionally, the panel said the CCA's stated interest in Congress' promotion of keeping families intact, as well as its long-standing assumption in the immigration context to lean in favor of the petitioner when ambiguities linger weighed in favor of Khalid's position.

An examination of the conditions of Khalid's juvenile detention also factored into the panel's decision. Congress in the Juvenile and Delinquency Prevention Act of 1974 showed a “clear preference for preserving the juvenile's connection” to his family during incarceration, with an emphasis on continued parental involvement during detention. Allowing the government's interpretation of “physical custody” under the circumstances would also appear to leave the question of a person's citizenship under the circumstances entirely up to a judge or magistrate, according to the panel, based on whether the juvenile was detained or returned to his or her family pending trial.

While the panel unanimously agreed, Jacobs and Hall, in a short concurring opinion, sought to limit the impact of the decision. They noted they were unable to congratulate Khalid on his new-found status. That he was able to retain his citizenship, despite “sneaking violence against Americans, who gave his family a home,” was “obtained only because the detention was pretrial, brief, and in a juvenile facility where, under federal law, Khalid's citizen father was allowed and encouraged to exercise influence over his son.”

“The holding of this case is surprising enough, and does not lend itself to expansion,” the duo stated.

Private attorney Wayne Sachs represented Khalid on appeal. In an emailed statement, he called the panel's decision “a very satisfying victory for a well-deserving young man with a bright future.”

“The Court finally accepted the simple statutory and legislative history arguments which were advanced and rejected by four previous courts, and in so doing, properly focused on the law rather than the petitioner's 'notoriety,'” Sachs said.

Requests for comment from the Department of Justice, which handled the appeal for the government, as well as DHS went not immediately answered.

Related: