The Associated Press

WASHINGTON — A federal judge on Wednesday ordered the government to allow a pregnant 17-year-old immigrant, who was detained after entering the country illegally, to undergo an abortion.

After a brief hearing that included a testy exchange with government lawyers, Judge Tanya Chutkan ordered the government to move “promptly and without delay” to transport the teenager or allow her to be transported by others to the nearest abortion provider.

The case originated in Texas, where the teen is being held by federal immigration authorities, and was brought to the U.S. District Court for the District of Columbia by the American Civil Liberties Union.

The teen, whose name has been withheld because she’s a minor, has already received a court order permitting her to have the abortion. But officials have refused to transport her or temporarily release her so that others may transport her to the clinic.

Wednesday’s hearing largely consisted of a contentious debate between Chutkan and Deputy Assistant Attorney General Scott Stewart, with the judge saying she was “astounded” by the government’s position.

Stewart argued that the teenager, referred to in court as either Jane Doe or JD, was free to return to her home country and seek an abortion there, but said “the government is entitled to favor childbirth” and shouldn’t be required to facilitate abortions.

She is being held at a facility in Texas administered under a contract from the U.S. Department of Health and Human Services, which is responsible for sheltering children who illegally enter the United States unaccompanied by a parent.

She’s believed to be about 15 weeks pregnant. Texas law bans most abortions after the 20th week of pregnancy and requires women seeking an abortion to meet with the doctor who will perform the procedure a day beforehand. The state also requires minors to get the consent of a parent or obtain a waiver from a judge.

Attorneys for the teenager say they obtained the waiver and scheduled several appointments with a doctor, but the facility that’s holding her refused to let her go. Instead, she was taken by the facility to a crisis pregnancy center. Such centers try to discourage women from having abortions and are often affiliated with religious groups.

“I do not want to be forced to carry a pregnancy to term against my will,” the teen said in a statement filed with the court Friday.

The teenager’s advocates argue that HHS has effectively tried to stop all minors in its custody from having abortions.

In one email obtained by the ACLU, Scott Lloyd, director of the HHS office that oversees facilities for unaccompanied children, directs a subordinate that facilities that get agency funding “should not be supporting abortion services,” but instead providing “only pregnancy services and life-affirming options counseling.”

In another, Lloyd asks about the status of a girl he met during a visit to a facility and offers to connect the teen with “a few good families” who would “see her through her pregnancy.”

In Wednesday’s hearing, Chutkan noted the government “had no problem transporting her against her will to pregnancy counseling where they attempted to change her mind.”

Stewart argued the teen was free to return to her home country and get an abortion there, but the judged challenged him on whether the government had a constitutional right to single out abortions and block immigrants in custody from undergoing the procedure.

“Residents of this shelter receive medical treatment all the time,” Chutkan said. “Why is this any different? Why is the fact that this is an abortion any different than if she was getting her tonsils out?”

After the hearing and before the judge issued her verdict, ACLU attorney Brigitte Amiri said it was clear the government had overstepped its bounds. “They took a position that was basically indefensible and they couldn’t defend it,” Amiri said.

HHS said in a statement last week about the 17-year-old immigrant’s case that it was “providing excellent care to the adolescent girl and her unborn child, who remain under our care until the mother’s release.” It did not respond to several requests for comment on the emails published by the ACLU.

In a court filing Tuesday, HHS argued it had a strong interest in “not providing incentives for pregnant minors to illegally cross the border to obtain elective abortions while in federal custody.”

Magistrate Judge Laurel Beeler of the U.S. District Court for the Northern District of California ruled last week that the government couldn’t prevent the teen from getting an abortion, but declined to an issue an order forcing officials to step aside. Beeler said her court was the wrong venue for the case, leading lawyers for the teenager to bring the case to the Washington, D.C., federal court.