Former US army analyst Chelsea Manning has been released from prison on a judge's order after being held since May for refusing to testify in an ongoing US investigation of WikiLeaks, the pro-transparency group.

US District Judge Anthony Trenga ordered Manning's release after prosecutors said the grand jury that subpoenaed her had disbanded. The Alexandria sheriff's office later confirmed Manning's release, which came a day after she attempted suicide in jail.

More:

"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 wrote, ordering Manning's release.

A detention hearing due on Friday was cancelled.

In 2010, Manning, a then-army intelligence analyst in Iraq, shared with WikiLeaks more than 700,000 classified documents related to the wars in Iraq and Afghanistan. She was sentenced to 35 years in a military prison but was released after seven years on the order of former US President Barack Obama.

Manning's leaks made her a hero to anti-war and anti-secrecy activists.

"I object to this grand jury ... as an effort to frighten journalists and publishers, who serve a crucial public good," Manning said in a letter to the court last year, according to the Sparrow Project support group.

Manning has also said she answered all questions about her involvement with WikiLeaks years ago.

On Wednesday, her defence team said Manning had attempted to commit suicide and had been taken to hospital, where she was recovering.

Spokesman Andy Stepanian said that despite her imprisonment and the imposition of financial sanctions - Manning is still liable for $256,000 in fines for her refusal to testify - the former army private remained "unwavering in her refusal to participate in a secret grand jury process that she sees as highly susceptible to abuse".

Prosecutors could possibly convene another grand jury and again subpoena Manning and she could again be jailed for refusing to testify. But there is no clear indication from prosecutors that they would do so.

WikiLeaks, an internet-based "dead letter drop" for leakers of classified or sensitive information, was founded by Australian citizen Julian Assange in 2006.

Assange is being held in a London prison as British courts consider a request from US prosecutors for his extradition to the United States. He is wanted on charges of conspiring with Manning to hack into a Pentagon computer system containing classified materials.