The Trump administration sought to block an undocumented teenager from having an abortion, though a federal judge on Wednesday rejected officials' claims they couldn't allow her to leave a shelter unless she exits the country or is released to a U.S. sponsor.

Lawyers from the Department of Justice (DOJ) defended a decision by the Department of Health and Human Services to not let the 17-year-old travel to a Texas clinic to obtain an abortion, BuzzFeed News reported.

The girl, identified in court as “Jane Doe,” has been fighting to have the abortion since she was first detained at the U.S. border with Mexico on Sept. 11.

The American Civil Liberties Union (ACLU) sued on the girl’s behalf, calling for an immediate court order to allow her to have the procedure, which was granted Wednesday.

U.S. District Judge Tanya Chutkan ordered the government to "promptly and without delay" allow the girl to visit a nearby abortion provider.

ADVERTISEMENT

Chutkan said she was “astounded” by the administration appearing to claim that the girl must carry her pregnancy to term or leave the U.S.

“Just because she’s here illegally doesn’t mean she doesn’t have constitutional rights,” Chutkan said.

A state judge ruled earlier that the teenager could have the abortion without the parental permission required in Texas, but the girl and her lawyers claim that government officials have blocked her from going to a clinic for the procedure.

Officials did allow the girl to travel to a religious center for counseling to dissuade her from terminating the pregnancy.

“The government certainly had no problem taking her against her will to receive pregnancy counseling,” Chutkan pointed out, according to BuzzFeed.

The girl is now 15 weeks pregnant. It is illegal to have an abortion in Texas after 20 weeks.

—Updated at 4:41 p.m.