The D.C. Circuit Court of Appeals on Friday said the Trump administration cannot deny pregnant undocumented minors in federal custody access to abortion.

In the opinion, the panel of judges wrote that they were "unanimous in rejecting the government's position that its denial of abortion access can be squared with Supreme Court precedent."

The judges said court precedent holds that "a person has a constitutional right to terminate her pregnancy before fetal viability, and the government cannot unduly burden her decision."

The opinion stated that the federal policy applies only to minors in federal immigration detention. It also said that undocumented migrants 18 years or older are allowed to obtain abortions.

The legal back-and-forth stems from the case of a 17-year-old girl, identified in legal documents as "Jane Doe," who arrived by herself in the United States in 2017.

The undocumented girl, whose nationality has not been disclosed, was placed in the care of the Office of Refugee Resettlement, a branch of the Department of Health and Human Services.

She obtained an abortion after suing the government in federal court. The Supreme Court last year decided the litigation could continue in lower courts to decide the fate of other undocumented pregnant minors.

In March 2017, the Office of Refugee Resettlement said shelters were "prohibited from taking any action that facilitates an abortion without direction and approval from the director," who at that time was Scott Lloyd.

Lloyd denied all abortion requests delivered to him during his tenure, even when the pregnancy resulted from rape, according to an appeals court ruling cited by Reuters.

Lloyd left his position at the end of 2018.

In its opinion Friday, the appeals court said the administration policy "functions as an across-the-board ban on access to abortion."