A gay US solider will have 112 days taken off his sentence if he is convicted of leaking thousands of classified files, on the grounds that he was subjected to excessively harsh treatment in military detention.

The material in question included 700,000 US diplomatic and military cables and footage of a July 2007 airstrike on Baghdad – which Private Bradley Manning’s supporters claim was covered up by US officials. 

Army Colonel Denise Lind ruled on Tuesday during a pre-trial hearing that Manning was illegally punished while in military custody at a base in Virgina after his arrest in 2010.

She said the abuse he suffered was so severe he should get 112 days cut from any prison sentence he receives if convicted.

From 29 July 2010 to 20 April 2011, Manning was held under constant surveillance, had his possessions removed from his cell and at times even his clothes, often in contravention to the professional medical opinion of psychiatrists.

The 25-year-old, who was held for 23 hours a day in a windowless environment, wants charges for giving secret files to the Wikileaks website to be dropped because of his ordeal.

Manning has previously claimed that he was bullied for being gay during his time in the US Army.

In May 2011, human rights campaigner Peter Tatchell described Manning as a “gay hero” and a “human rights defender”.

The former intelligence analyst faces 22 charges, including aiding the enemy. If convicted, he could be jailed for life.

His trial is expected to start on 6 March.