A federal judge has ordered that Chelsea Manning be released from jail in Virginia.

The former US army analyst who leaked hundreds of thousands of documents and diplomatic cables to WikiLeaks in 2010 had been held since May last year, when she was taken back into custody for refusing to testify to a grand jury investigating the pro-transparency organisation.

A hearing had been due on Friday.

Ordering Manning’s release, Judge Anthony J Trenga wrote: “The court finds Ms Manning’s appearance before the grand jury is no longer needed, in light of which her detention no longer serves any coercive purpose.”

Trenga rejected a request by Manning to cancel fines imposed for her refusal to testify, ordering instead that a judgment be entered against Manning for $256,000.

On Wednesday, representatives for Manning said she had attempted suicide at the Alexandria adult detention center.

In a statement, Manning’s representatives said she “has previously indicated that she will not betray her principles, even at risk of grave harm to herself.

“Her actions today evidence the strength of her convictions, as well as the profound harm she continues to suffer as a result of her ‘civil’ confinement.”

Dana Lawhorne, the Alexandria sheriff, said the incident “was handled appropriately by our professional staff and Ms Manning is safe”.

No further details were released.

Manning served six years in military custody for her part in the 2010 WikiLeaks disclosure, which was made via media outlets including the Guardian. Barack Obama commuted the rest of her 35-year sentence shortly before the end of his time in office.

Manning attempted suicide twice while held on the original charge, during which time she was held in solitary confinement, mounted a hunger strike and completed gender reassignment.

After her release she mounted a run for Senate in Maryland, a failure which she told the Guardian left her “closer and closer to being on the edge of really deep, dark depression”.

She also said she had been “exhausted” when, in May 2018, she tweeted a picture apparently showing her standing on a ledge several storeys above the ground.

Manning was first jailed for refusing to testify in March that year. She was released and then taken back into custody, telling the judge she would “rather starve to death” than appear before the grand jury.

In February this year she petitioned for her release, comparing her experience with the Trump administration’s defiance of congressional subpoenas.

Manning wrote that she had been “separated from my loved ones, deprived of sunlight, and could not even attend my mother’s funeral”.

She added: “It is easier to endure these hardships now than to cooperate to win back some comfort, and live the rest of my life knowing that I acted out of self-interest and not principle.”

An extradition hearing for Julian Assange, the founder of WikiLeaks, continues in London. In the US, Assange is charged with violating the Espionage Act.