A federal appeals court on Tuesday sided with an illegal immigrant teenager in her effort to obtain an abortion while being held in U.S. custody in Texas.

The D.C. Circuit Court of Appeals ruled in favor of the pregnant teenager, contrary to a three-judge panel decision from the court last week.

The 6-3 decision sends Garza v. Hagan back to a lower court to determine the timing of the procedure. One presiding judge, Nina Pillard, did not participate and is not included in the 6-3 tally. The girl, who is in federal custody, is 16 weeks pregnant. Texas blocks most abortions after 20 weeks.

The teen followed state law in obtaining permission from a Texas state judge to have the abortion and indicated she would pay for the termination of her pregnancy with her own money or help from her court-approved guardian.

The Trump administration argued that the 17-year-old was not entitled to an abortion, and the Justice Department advocated for a solution that could have forced the teenager to choose between staying in the U.S. or having the abortion.

The federal appeals court ruling against the Trump administration was a "per curiam" opinion, meaning it was delivered on behalf of the entire court rather than signed by an individual judge writing the opinion.

In a concurring opinion, Judge Patricia Millett blasted the Trump administration. Millett was appointed to the federal appeals court by former President Barack Obama in 2013.

"Fortunately, today's decision rights a grave constitutional wrong by the government," Millett wrote. "Remember, we are talking about a child here. A child who is alone in a foreign land. A child who, after her arrival here in a search for safety and after the government took her into custody, learned that she is pregnant. J.D. then made a considered decision, presumably in light of her dire circumstances, to terminate that pregnancy. Her capacity to make the decision about what is in her best interests by herself was approved by a Texas court consistent with state law. She did everything that Texas law requires to obtain an abortion. That has been undisputed in this case."

Three judges dissented, including Judges Brett Kavanaugh, Karen LeCraft Henderson and Thomas B. Griffith. Kavanaugh, a former law clerk to Justice Anthony Kennedy who has been floated as a potential replacement for Kennedy should he choose to retire, wrote a dissent joined by his two colleagues.

"The Supreme Court has repeatedly held that the government may further those interests so long as it does not impose an undue burden on a woman seeking an abortion," Kavanaugh wrote. "Today's majority decision, by contrast, 'substantially' adopts the panel dissent and is ultimately based on a constitutional principle as novel as it is wrong: a new right for unlawful immigrant minors in U.S. government detention to obtain immediate abortion on demand, thereby barring any government efforts to expeditiously transfer the minors to their immigration sponsors before they make that momentous life decision."

Planned Parenthood praised the federal appeals court's decision.

"It's time for the Trump administration to respect Jane Doe and her constitutional right to access safe, legal abortion," said Cecile Richards, Planned Parenthood Federation of America president. "We hope that this ruling sends a strong signal to the Trump administration. Access to safe, legal abortion is the law. Every woman deserves access to basic healthcare, including abortion, regardless of her immigration status."