A federal judge in Washington has ordered the Trump administration to allow a detained teenage who is in the U.S. illegally to have an abortion.

The 17-year-old, identified in court documents only as "Jane Doe," is being held in a private facility in Texas after she was apprehended crossing the U.S.-Mexico border last month. She is 15 weeks pregnant and has asked for an abortion.

Lawyers for the Trump administration argued that because the teenager is not a citizen, she doesn't have a constitutional right to an elective abortion while in federal custody, except in case of a medical emergency. U.S. District Judge Tanya Chutkan disagreed. She ordered the government to transport the teenager, or allow her guardian to transport her, to have the procedure "promptly and without delay."

The order also restrains government officials from interfering with or obstructing the teenager's decision to have an abortion.

As NPR's Sarah McCammon reported last week, the dispute pits immigration advocates and the American Civil Liberties Union against anti-abortion rights groups and officials at the Department of Health and Human Services.

Under Texas law, minors need parental consent or a judge's permission to obtain an abortion. In a previous legal filing, the ACLU said the girl, known in the case as Jane Doe to protect her privacy, has obtained that permission, but the government has blocked her from leaving the shelter for that purpose.

"The ACLU said federal officials required the girl to undergo counseling and an ultrasound at a crisis pregnancy center, an anti-abortion organization that does not provide abortion services," wrote McCammon.

The fact that HHS officials had sent the young woman to abortion counseling against her will but were unwilling to comply with her desire for an abortion apparently irked Judge Chutkan. The Washington Post reports that the judge, an Obama administration appointee, and deputy assistant attorney general Scott Stewart, "sparred" in a hearing Wednesday over the question of whether undocumented immigrants are protected by the Constitution.

Stewart argued that immigrants in the U.S. without permission have minimal constitutional protections and that the government has an interest "in preserving life and protecting national boundaries," according to the Post.

In a statement, ACLU lawyer Brigitte Amiri said "At last, our client will be able to get the care she needs without federal officials standing in the way... no one should have to go to court to get a safe, legal abortion. And no one should be held hostage to the extreme anti-abortion views of a handful of government officials."

The president and CEO of Americans United for Life, Catherine Glenn Foster condemned the ruling.

"Americans United for Life is deeply disappointed that once again, an activist judge has declared abortion 'access' more important than U.S. law and policy that prohibits federal funding and support of elective abortion," said Foster in a statement.

Copyright 2017 NPR. To see more, visit http://www.npr.org/.