Justice Brett Kavanaugh’s old court rebuked his anti-abortion jurisprudence on Friday, compelling the Trump administration to allow undocumented minors in federal custody to terminate their pregnancies. The appeals court’s ruling rejects the administration’s blanket ban on abortion access for these minors as a violation of their constitutional right to choose. It should guarantee all undocumented minors control over their bodies, a right the federal government has spent more than two years seeking to revoke.

Friday’s decision is the latest chapter in a controversy that began in March 2017. That month, then–Director of the Office of Refugee Resettlement Scott Lloyd announced that minors in federal custody could not obtain abortions without his permission, which he flatly refused to grant. Instead, Lloyd urged pregnant minors not to get abortions and called their parents—without their consent—to inform them that their children were pregnant. He also tracked minors’ periods and pregnancies on a spreadsheet, apparently to determine when they were too far along to obtain a legal abortion. Lloyd even barred abortions for minors whose pregnancies resulted from rape, declaring that forcing these teenagers to give birth was in their “best interest.”

Friday’s decision is the latest chapter in a controversy that began in March 2017.

The ACLU brought a class-action lawsuit on behalf of these minors asking the courts to block Lloyd’s policy. It also represented individual minors, including a 17-year-old known as Jane Doe, who urgently sought abortions while the class action was pending.

In October 2017, then-Judge Kavanaugh refused to let Doe, who was housed in Texas, get an abortion—even though she was 15 weeks pregnant and had already obtained judicial bypass pursuant to state law. Instead, Kavanaugh gave the government more time to find a sponsor who could take custody of Doe and maybe let her obtain an abortion. The full U.S. Court of Appeals for the District of Columbia Circuit swiftly reversed Kavanaugh’s decision, allowing Doe to terminate. In response, Kavanaugh penned a fiery dissent accusing the majority of permitting “immediate abortion on demand.” He described Lloyd’s ban as nothing more than “government efforts to help minors navigate what is undeniably a difficult situation” through “reasonable regulations.”

Following that decision, Doe quickly obtained her abortion. A furious Department of Justice then asked the Supreme Court to punish the ACLU attorneys who represented Doe, falsely accusing them of misconduct. SCOTUS declined this invitation, but also vacated the D.C. Circuit’s decision because it had become moot since Doe got the relief she wanted. So the ACLU pressed on with its class action. Meanwhile, Judge Kavanaugh became Justice Kavanaugh and continued to vote against abortion rights.

Now the D.C. Circuit has blocked the administration’s abortion ban altogether, permitting all undocumented minors in federal custody to access abortion care. Judges Sri Srinivasan and Robert Wilkins, both Obama appointees, agreed that minors could sue as a class, and held that the ban imposes an unconstitutional “undue burden” on their right to choose.

The majority shredded the DOJ’s justification for the administration’s ban. First, the DOJ argued that the government may decline to “facilitate” abortion access—but, the majority explained, minors are merely asking “the government to step out of the way.” They are not seeking facilitation of abortion but rather the ability to leave their shelter and undergo the procedure. Second, the DOJ argued that minors should self-deport and get an abortion in their country of origin. But the vast majority of these minors’ home countries criminalize abortion, so that option does not actually exist. Moreover, the Supreme Court has found that compelling women to leave their state to get an abortion constitutes an undue burden; surely, then, forcing them to leave the country is similarly unconstitutional.

Third, the majority responded to Kavanaugh’s claim, echoed by the DOJ, that minors should simply find a sponsor willing to take them in and get permission from there. This process, however, is not so simple. “Release to a sponsor,” the majority noted, “is at the discretion of the government and is contingent on factors outside the [minor’s] control—most importantly, the existence of a willing and qualified sponsor.” This process “involves many steps,” including “evaluation of the suitability of the sponsor,” “background checks,” and “home studies,” which take, on average, 90 days. Some minors—including one whose pregnancy resulted from rape—never find a qualified sponsor. In the government’s view, minors can be forced to wait for a sponsor until their pregnancies can no longer be legally terminated. “That of course cannot be so,” the majority concluded. A woman’s constitutional right cannot be conditioned on the “abstract availability” of a sponsor who may never materialize.

Finally, the government argued that it did not want to permit “abortion tourism,” allowing minors “who cannot obtain abortions lawfully in their country” to “demand abortion services at our border.” It wanted to deter these hypothetical minors by forcing those who come to the U.S. to carry unwanted pregnancies to term. The majority found it unlikely that minors would risk the extremely dangerous migration, rife with “violence and sexual assault,” merely to get an abortion. And besides, “we cannot accept the suggestion that minors in ORR custody should be compelled to carry pregnancies to term against their wishes—even in cases of rape—so that others will be deterred from desiring to come here.”

With this and its firm rejoinder to Kavanaugh’s 2017 dissent, the majority prohibited the government from enforcing its abortion ban on minors in federal custody. It sent the case back down to the district court to further evaluate the government’s policy of disclosing minors’ pregnancy status to their family members, because the “contours” of this notification policy remain hazy. The upshot is that every minor like Jane Doe should now be allowed to terminate her pregnancy if she so chooses. This result infuriated Judge Laurence Silberman, who penned a sharp dissent asserting that the majority’s decision “justifies Judge Kavanaugh’s accusation that the court is endorsing abortion on demand.”

What happens next? The Justice Department will likely appeal to the Supreme Court, where Kavanaugh should recuse because of his involvement in the Jane Doe litigation. (He has previously recused himself from disputes in which he participated on the D.C. Circuit.) If SCOTUS takes the case and divides 4–4, its deadlock will affirm the D.C. Circuit’s ruling. For now, at least, minors’ constitutional right to choose should remain safe, and Kavanaugh should not be able to enshrine his 2017 dissent into law. The justice should eventually have a chance to cast a fifth vote gutting Roe v. Wade, but it likely won’t arrive in this case.

There is one important postscript to this story. Lloyd, who defended his abortion ban as an effort to protect children, played a key role in the family separation crisis. As director of ORR, Lloyd failed to track children taken from their parents at the border and ignored warnings about the devastating impact of family separation on children’s health. He allegedly directed his staff to stop keeping a spreadsheet tracking parents and children who had been separated and botched the court-ordered reunification of families. An internal review found that Lloyd had mismanaged the office, and he was removed from his post in late 2018, though ORR maintained his abortion ban. Lloyd now works at the Department of Health and Human Services’ Center for Faith and Opportunity Initiatives, where he will hopefully have no control over children’s bodies.