Image caption Bradley Manning's trial is expected to start in March

Alleged Wikileaks source Bradley Manning will have 112 days taken off his sentence if he is convicted, a US military judge has ruled.

The judge said at a pre-trial hearing that Pfc Manning had suffered illegal punishment during his nine-month detention after his arrest in 2010.

The 25-year-old was held for 23 hours a day in a windowless cell.

Pfc Manning wants charges for giving secret files to the Wikileaks website to be dropped because of his ordeal.

In all, the former intelligence analysts faces 22 charges, including aiding the enemy. If convicted, he could be jailed for life.

His trial is expected to start on 6 March.

Suicidal thoughts

At the start of the four-day pre-trial hearing in Fort Meade, Maryland, Judge Denise Lind ruled that Pfc Manning's confinement was "more rigorous than necessary".

She said that his detention conditions "became excessive in relation to legitimate government interests".

He was confined to a windowless cell 23 hours a day, sometimes with no clothes, at a US Marine Corps prison in Virginia. He was also shackled while outside his solitary cell.

The military argued that stringent measures were necessary to prevent the suspect from harming himself.

But his defence lawyers said that the procedures lasted well past the time when he was having suicidal thoughts and therefore amounted to illegal punishment.

The judge granted 20 days credit in exchange for guards continuing to remove Pfc Manning's underwear at night and 10 days for denying him exercise, the Pentagon said.

Judge Lind refused a defence request to reduce any sentence by 10 days for every day of his nearly nine months of being held with excessive treatment - which would have reduced any sentence by more than seven years, the UK's Guardian newspaper reported.

Instead, she agreed to a day-for-day ratio, calculating that 112 days of the nine-month period should be compensated for receiving unduly harsh treatment, the paper said.

Pfc Manning has offered to take responsibility for leaking more than 250,000 diplomatic cables and classified files to Wikileaks.

But the government is still planning to prosecute him on all 22 charges.

"The charges are serious in this case," said Judge Lind.