ALEXANDRIA, Va. — A federal judge ordered Chelsea Manning, the former U.S. Army intelligence analyst who spent four years in prison for providing classified information to WikiLeaks, to be jailed Thursday after she refused to cooperate with a grand jury investigation related to the anti-secrecy group.

"I would rather starve to death than to change my opinion in this regard. And when I say that, I mean that quite literally," Manning said during a hearing Thursday afternoon in federal district court in Alexandria, Virginia, where Manning will be jailed for no longer than 18 months, the maximum term for federal grand juries.

U.S. District Judge Anthony Trenga said that Manning refused to testify because of a philosophical objection to the use of grand juries and that Manning has persisted in her refusal.

Moira Meltzer-Cohen, Manning's attorney, said she's disappointed with the judge's decision. She argued that Manning is "famously principled" and jailing her again is useless because no amount of incarceration can force her to relent.

"She is not going to cooperate with this grand jury. She knows it. I know it. Her friends and family know it," Meltzer-Cohen said in court.

G. Zachary Terwilliger, U.S. attorney for the Eastern District of Virginia, said he still hopes Manning will change her mind. He declined to answer what steps his office will take if Manning continues to refuse after the term of the grand jury expires.

More:Chelsea Manning jailed for contempt after refusing to testify in WikiLeaks grand jury investigation

Like what you're reading?:Download the USA TODAY app for more

"The only thing that's being asked of her was to answer questions truthfully," Terwilliger told reporters, adding that Manning had been granted immunity from self-incrimination.

Manning was jailed for contempt in March after she refused to testify before the grand jury, saying she's against the inquiry and she had already provided the government "extensive testimony" during her prosecution six years ago. She was released last week after the grand jury's term expired.

Prosecutors summoned her to appear again Thursday in front of a new grand jury, though she promised not to cooperate. After she made good on that promise, Trenga held her in contempt and ordered that she be jailed immediately. She also faces fines of $500 a day if she doesn't cooperate within a month, and $1,000 a day if she still refuses to testify after two months.

Speaking to reporters before her scheduled grand jury appearance Thursday afternoon, Manning said the subpoena was simply an attempt to put her back behind bars and relitigate her previous prosecution for leaking classified information to WikiLeaks. She said prosecutors are just asking her "broad and generic" questions she had already answered.

Meltzer-Cohen argued in court that further incarceration will unnecessarily punish Manning and put her health at risk. Manning, a transgender woman, recently underwent a major surgery and has medical needs that won't be accommodated in the Alexandria Detention Center. Medical staff at the jail aren't trained to address the "post-surgical needs" of a transgender woman, Meltzer-Cohen said.

Terwilliger said medical staff at the jail had already "bent over backwards" to accommodate Manning's medical needs and is fully equipped to do so again. Prosecutors argued in court that they don't want Manning to be jailed, but incarceration will "coerce" her to fulfill her responsibility of testifying before the grand jury. They also said that Manning's criticisms of the use of a grand jury are unfounded.

Manning's attorneys had previously declined to say what information the government is seeking. But last year, federal prosecutors in the same federal district court inadvertently disclosed in court documents that criminal charges had been filed under seal against WikiLeaks founder Julian Assange.

More:Julian Assange, WikiLeaks founder, faces US hacking conspiracy charge

The indictment against Assange was filed under seal in March 2018 and was made public last month, when Assange was arrested to face a conspiracy charge in the United States. Prosecutors alleged that Assange conspired with Manning to steal and publish a large cache of top-secret files from military computers. They said Assange helped Manning crack a password to access a Pentagon computer system.

Manning's attorneys argued that compelling her to testify isn't lawful, saying grand juries are intended only for investigative purposes and not to prepare for trial in the pending criminal case against Assange.

Complicating the U.S. effort to try Assange is a separate prosecution in Sweden, where investigators have reopened a rape case over an incident that allegedly happened 10 years ago. Authorities in Sweden have also sought extradition.

Assange's arrest last month came after nearly seven years of self-imposed exile inside the Embassy of Ecuador in London. He was forcibly taken into custody after Ecuadorian officials revoked his political asylum. The 47-year-old Australian national sought asylum in the embassy in 2012 to avoid extradition to Sweden, where he was wanted for questioning in the rape case.

Manning's case has attracted heightened attention because of her status as a transgender soldier. She was sentenced to 35 years in prison in 2013 for her role in leaking a cache of classified government material to WikiLeaks. At the time, she was known as Bradley Manning. President Barack Obama commuted her sentence in 2017.

Contributing: Kevin Johnson, Bart Jansen and Kim Hjelmgaard