The Long Creek Youth Development Center in South Portland has struggled to handle its large population of young inmates with serious mental illness.

With the transfer last week of a juvenile who has been held at Long Creek Youth Development Center for nine months to a residential treatment facility, the state wants the case challenging the constitutionality of his detention to be dismissed.

The boy, now 14, was moved to Becket’s Mount Prospect Academy in Plymouth, New Hampshire, on Aug. 8. Assistant Attorney General Jason Anton the next day filed a motion to dismiss an appeal pending before the Maine Supreme Judicial Court.

Anton argued that because the juvenile, identified by the initials A.I. in court documents, “has received the very relief that he seeks on appeal,” it should be dismissed as moot.

A.I.’s attorney, Sarah Branch of Lyman, said Wednesday that she opposes the dismissal of the appeal. A number of organizations that agree with Branch’s legal arguments also believe the case should go forward.

“The legal community and the larger community need to see if the state can imprison a child constitutionally,” she said. “We need to know if the state can still be allowed to do this in the future to other children.”

A.I.’s prolonged detention has helped fuel a discussion about the state’s juvenile justice system. Some advocates have called for Maine’s last juvenile detention center to be shut down and that more money be spent on building residential treatment facilities. A task force is studying alternatives to incarceration for juveniles, including young people at risk of being involved in the justice system, with a report due to the Legislature by early 2020.

The boy has been in and out of Long Creek since he was 11. In April, a District Court judge found that he was incompetent to be tried on midemeanor charges but most likely could become competent in the future. The judge ordered that A.I. receive competency restoration services at Long Creek but he did not, according to court documents filed in Portland. The state also could not find a residential treatment facility in Maine that could meet A.I.’s needs, so he remained at the South Portland juvenile detention center.

If A.I. had been an adult and found incompetent but likely to be restored to competency, he most likely would have been moved to Riverview Psychiatric Center in Augusta for evaluation and treatment in a hospital setting.

“We need a 10- to 15-bed facility that is the equivalent of a juvenile Riverview,” Branch said. “We just don’t have that kind of hospital level of care and restorative treatment for juveniles in this state.”

Mount Prospect Academy does not appear to be that kind of facility. It serves 85 male students, who range in age from 11 to 21, according to information on its website.

The school’s mission is “to provide a caring, safe therapeutic environment where students have the opportunity to grow and acquire the skills they need to reach their educational and social potential. We aim to develop trusting relationships with students and facilitate experiences that promote their ability to self-regulate, manage thoughts and feelings, and develop feelings of safety, confidence and competency.”

A.I., whose mother refused until June to allow him to be moved out-of-state for treatment, has been diagnosed with Attention Deficit Hyperactivity Disorder and Disruptive Mood Dysregulation Disorder, according to court documents. He also has several deficits associated with the frontal lobe of the brain, which is the part of the brain responsible for controlling emotions and impulses.

Branch said Wednesday that she has not yet talked to her client since he arrived at the school but was told his is adjusting well.

The appeal pending before the Maine Supreme Judicial Court argues that incarcerating a juvenile violates the due process clause of the 14th Amendment to the U.S. Constitution. On Tuesday, the ACLU of Maine, the Disability Rights Center of Maine, Kids Legal Maine, the Juvenile Law Center, based in Philadelphia and the GLBTQ Legal Advocates and Defenders, based in Boston, filed a “friend of the court” brief in support of A.I.’s appeal.

It said that courts have held that incarceration of incompetent defendants held from eight to 28 days violates the constitution.

“These constitutional concerns are even greater when we consider the injustice of unnecessarily incarcerating juveniles — who are entitled to even greater state protection than adults,” the brief said. “The research is clear that incarceration is harmful to youth; it increases recidivism rates, results in physical harm, worsens educational and employment outcomes, and damages mental health.

“In the context of a child who is incompetent to stand trial, moreover, each of these tragic consequences of incarceration runs directly contrary to the state’s sole legitimate interest in restoring competency to stand trial,” it said.

The case has not been set for oral argument.

A.I. has civil rights case pending in U.S. District Court in Portland filed on his behalf by the ACLU of Maine. It alleges that staff at Long Creek used excessive force when they knocked out his front teeth in July 2017. That lawsuit is pending. Attorneys for the Maine Department of Corrections that runs Long Creek have said they will file a motion for summary judgment before the end of the year.