The US soldier accused of being behind the massive WikiLeaks publication of state secrets has been awarded a 112-day reduction in any eventual sentence on the grounds that he was subjected to excessively harsh treatment in military detention.

Colonel Denise Lind, the judge presiding over Bradley Manning's court martial, granted him the dispensation as a form of recompense for the unduly long period in which he was held on suicide watch and prevention of injury status while at the brig at Quantico marine base in Virginia where he was detained from 29 July 2010 to 20 April 2011.

During that time he 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.

Lind's ruling was made under Article 13 of the Uniform Code of Military Justice that protects prisoners awaiting trial from punishment on grounds that they are innocent until proven guilty. The recognition that some degree of pre-trial punishment did occur during the nine months that the soldier was held in Quantico marks a legal victory for the defence in that it supports Manning's long-held complaint that he was singled out by the US government for excessively harsh treatment.

However, the ruling falls far short of the hopes of Manning's defence team. At best, the soldier's lawyers had pressed for a dismissal of all 22 counts that he is currently facing relating to the transfer of hundreds of thousands of US diplomatic cables and war logs to the whistleblower website WikiLeaks.

Dismissal of all charges is listed as a possible remedy for an Article 13 violation. But Lind said it should be used only under the most egregious circumstances where the US government has engaged in outrageous conduct.

"The charges are serious in this case and there was no intent to punish. There is no argument to dismiss the charges," the judge said.

Beyond dismissal, the defence had called for a diminution of Manning's sentence according to a ratio of 10 days reduction for every day of excessive treatment, to run for the entire duration of the nine months of the soldier's confinement at Quantico. That would have resulted in more than seven years being taken off his sentence.

But in the end, the judge agreed only to a straight day-for-day ratio, and further limited the duration of the reduction to narrowly defined periods where she found excessive treatment had taken place.

Specifically, she granted Manning seven days off any sentence for the seven days when he was kept on the most restrictive regime, known as Suicide Risk, against the advice of psychiatrists – the only Article 13 violation accepted by the prosecution; 75 days off sentence for when he was kept on the only slightly less onerous status of "prevention of injury", also against professional opinion; 20 days for having his underwear removed unduly after he made a joke that he could use that to harm himself; and 10 days for being granted just 20 minutes of recreation outside his cell every day when he should have been given a full hour.

In her ruling, Lind rejected several of the key arguments that had been put forward by the defence as evidence of pre-trial punishment. Manning's legal team tried to show that the military hierarchy had taken an inappropriate interest in the terms of Manning's confinement right up to the level of Lt Gen George Flynn in the Pentagon.

But Lind ruled that Flynn had acted appropriately to ensure that the brig staff followed procedures correctly and that they took the "high ground". She found that there had been no intention to punish the inmate on the part of the brig staff or the chain of command, who were motivated purely by a desire to ensure that the soldier did not harm himself and that he would be available to stand trial.

She also dismissed complaints concerning Juan Mendez, the UN rapporteur on torture, and the former US congressman Dennis Kucinich, who were both refused permission to visit Manning in Quantico. Lind said there was no requirement under military regulations to grant them access, and they were not on the prisoner's visitation list.

The battle for the defence now turns to the charges that Manning is facing. The most potentially devastating is the accusation that by passing information to WikiLeaks, he effectively made it available to al-Qaida and its affiliate terrorist organisations.

That charge, that he "aided the enemy" carries a possible maximum sentence in this case of life in military custody without any chance of parole. Manning is certain to plead not guilty to that charge, and has offered to plead guilty to a range of lesser charges in the hope that the prosecution will drop the "aiding the enemy" count.