(CN) — A federal judge on Friday night ruled the Trump administration can’t interfere with the ability of pregnant immigrant teens being held in federal custody to obtain abortions.

In a 28-page ruling, U.S. District Judge Tanya Chutkan said while the government is “certainly entitled to maintain an interest in fetal life,” it can not “create or implement any policy that strips [unaccompanied immigrant minor children] of their right to make their own reproductive choices.”

The order covers pregnant minors being held in federal custody after entering the country illegally.

Lawyers for the Department of Health and Human Services, which is responsible for sheltering children who illegally enter the country unaccompanied by a parent, have said the department has a policy of “refusing to facilitate” abortions.

Defendant Eric Hargan, the deputy secretary of the department, has gone a step further, saying he believes teens in his agency’s care have no constitutional right to abortion.

The American Civil Liberties Union sued the government on behalf of the minors, which the judge overseeing the case also Friday allowed to go forward as a class action lawsuit.

“We have been able to secure justice for these young pregnant women in government custody who will no longer be subject to the government’s policy of coercion and obstruction while the case continues,” said ACLU attorney Brigitte Amiri after the judge’s order became public.

The government can appeal the judge’s order. The Justice Department did not immediately respond to an emailed request for comment Saturday morning

The ACLU and Trump administration have been sparring for months over the government’s policy.

In 2017, the ACLU represented a teen who entered the U.S. illegally in September and learned while in federal custody in Texas that she was pregnant.

She obtained a state court order permitting her to have an abortion, but federal officials refused to transport her or temporarily release her so that others could take her to get the procedure. The teen was ultimately able to get an abortion in October as a result of the lawsuit, but the Trump administration has accused the ACLU of misleading the government during the case, a charge the ACLU has denied.

The ACLU has since represented several other teens who have sought abortions while in custody. Judge Chutkan’s order covers any teens currently in custody or who come in to custody while the lawsuit goes forward.

The Associated Press contributed to this report.