NEW YORK (AP) — A one-time Maryland high school honors student who admitted aiding Muslim extremists overseas and helped the U.S. pursue terrorists after his 2011 arrest is a U.S. citizen, a federal appeals panel said Thursday as it erased a pending deportation order.

The ruling by the 2nd U.S. Circuit Court of Appeals in Manhattan means 24-year-old Mohammad Hassan Khalid can continue his studies at a Maryland college.

His Philadelphia lawyer, Wayne Sachs, called the decision a “very satisfying victory for a well-deserving young man with a bright future.”

ADVERTISEMENT

He said the three-judge appeals panel, unlike four earlier courts, “properly focused on the law rather than the petitioner’s ‘notoriety.’”

The U.S. government did not immediately say if it planned to appeal.

Circuit Judge Dennis Jacobs wrote that he cannot congratulate Khalid, given that he “plotted sneaking violence against Americans.”

“He cooperated with the authorities only when, having been caught, he found himself needing another kind of refuge,” Jacobs said.

Circuit Judge Christopher F. Droney, who wrote the main opinion, explained that Khalid was entitled to citizenship because he was under age 18 when his father gained citizenship.

In a footnote, the 2nd Circuit noted that the government indicated that it had no information that Khalid presents a continuing threat to the United States.

The appeals court also noted that Khalid maintained that he would be tortured if removed to Pakistan because of his cooperation in federal terrorism investigations. The Department of Homeland Security had sought to remove him to the United Arab Emirates or Pakistan.

Khalid entered the United States in 2007 with his family. He was born in the United Arab Emirates, but was a Pakistani citizen because his parents were Pakistani.

Khalid was 17 when he was arrested in 2011 after winning a full scholarship to prestigious Johns Hopkins University. Authorities said he had been engaging in radical Islamist chat rooms from his family’s small apartment near Baltimore since he was 15.

In 2012, he pleaded guilty to conspiracy to provide material support to terrorists, admitting that he had agreed in his secret online life to raise money and recruit terrorists for jihad.

In 2014, he was sentenced to five years in prison. Prosecutors said he deserved leniency from a potential 15-year term because he had helped U.S. authorities pursue various al-Qaida offshoots after his arrest.

Khalid, who completed his sentence in 2015, is currently attending college in Maryland, studying cybersecurity, among other things.

His lawyer said Khalid is devoted to preventing young people from going down the path had had taken as a teenager.