A US judge has reduced the scale of the likely sentence for a soldier accused of passing reams of secret government files to the WikiLeaks website.

A total of 112 days will be shaved off any prison term for Private Bradley Manning, who Judge Denise Lind says has been harshly treated since he was locked up nine months ago.

Judge Lind said Manning's detention conditions were "excessive" and at times illegal and went beyond what was necessary to ensure his safety and prevent the risk of suicide.

However she rejected a request by defence lawyers to dismiss all charges against Manning because of his detention at the US Marine Corps prison in Quantico, Virginia.

The ruling paved the way for a trial in March in which Manning is accused of aiding the enemy by passing a trove of secret government files to the WikiLeaks website.

The 25-year-old was arrested in May 2010 while serving as an intelligence analyst near Baghdad and charged over the largest leak of restricted documents in American history.

Defence attorney David Coombs argued the court should drop all charges against Manning on the grounds that he suffered illegal punishment at the Quantico jail, where he was held in a solitary cell 23 hours a day, kept under a strict suicide watch, and often ordered to strip naked.

Prosecutors said the strict measures were necessary because Manning posed a suicide risk.

Bradley Manning leaves the court hearing in Fort Meade ( AFP )

Judge Lind concluded the government had to ensure Manning did not take his life given his mental health history, as he had reported suicidal thoughts while detained in Kuwait.

"Preventing a detainee suicide is in the legitimate interest of the government," Judge Lind said.

But she ruled prison authorities at Quantico should not have kept Manning under a rigorous super-strict suicide watch regime after military psychiatrists advised he was not suicidal.

"Prison officers had no reason to take away Manning's underwear at one point as no new threat had emerged and it was no longer reasonable to withhold the underwear," she said.

Judge Lind cited a seven-day period in which Manning was assessed by psychiatrists as no longer at risk of suicide but was still kept under strict isolation, saying it constituted unlawful pre-trial punishment.

If convicted on 22 charges, Manning would receive credit for his time behind bars in Quantico, with his potential sentence reduced by 112 days.

Judge Lind was not ready to call off the trial over Manning's treatment at the Quantico jail, though, because of the seriousness of the charges.

The ABC's North America correspondent, Jane Cowan, attended the hearing, and says the ruling is a small win for the defence.

ABC/AFP