HOUSTON — A pregnant undocumented teenager in federal custody whose attempt to have an abortion set off a monthlong legal battle with the Trump administration terminated her pregnancy on Wednesday morning. She underwent the procedure a day after a court ruling forced federal officials to allow it.

The teenager, who is 17 and is identified in court documents as Jane Doe, illegally crossed the border in Texas in early September and was apprehended. Her pregnancy was discovered during a physical exam, and since then she had been fighting in court to have an abortion.

In a statement released by her lawyers and her court-appointed guardian, Jane Doe, who had been nearly 16 weeks pregnant, wrote of coming to the United States with dreams of one day becoming a nurse, and of not being ready to be a parent.

“My lawyers have told me that people around the country have been calling and writing to show support for me,” Jane Doe wrote in her statement. “I am touched by this show of love from people I may never know and from a country I am just beginning to know — to all of you, thank you. This is my life, my decision. I want a better future. I want justice.”