WASHINGTON — Chelsea Manning, the former Army intelligence analyst who provided archives of secret military documents to WikiLeaks in 2010, was taken into custody on Friday after a federal judge found her in contempt for refusing to testify before a grand jury that is investigating the antisecrecy group.

Judge Claude H. Hilton of Federal District Court in the Eastern District of Virginia ruled that Ms. Manning must stay in civil detention until she testifies. Ms. Manning had vowed not to cooperate in the investigation even though prosecutors in the Eastern District of Virginia granted immunity for her testimony.

In a statement posted on Twitter after she was arrested, Ms. Manning said she had ethical objections to the secrecy of the grand-jury system and “will not comply” with the subpoena.

The case is part of a long-running criminal inquiry into WikiLeaks and its leader, Julian Assange, that dates to the Obama administration and which the Trump administration revived. Ms. Manning said on Thursday that prosecutors on Wednesday had asked her a series of questions about WikiLeaks before the grand jury, but she had responded to every question by saying it violated her constitutional rights.