Two undocumented immigrants in United States custody must be allowed to have abortions, a federal judge ruled on Monday, objecting to a Trump administration policy.

The immigrants, both 17, entered the United States illegally and are being held in government-run shelters. Under a policy announced in March by the Department of Health and Human Services’ Office of Refugee Resettlement, federally funded shelters cannot take “any action that facilitates” an abortion for an unaccompanied minor without the approval of the office’s director.

Department officials argue that the teenagers, referred to in court documents as Jane Roe and Jane Poe, can obtain abortions by returning to their home countries or finding an American sponsor. But Judge Tanya S. Chutkan noted in her order on Monday that the approval process for potential sponsors is long and complex. In fact, one of Roe’s relatives — a United States citizen — has filed an application but has yet to complete the vetting requirements.