Some of what caused misery in Manning's life - his broken family, chronic loneliness, his homosexuality and gender-uncertainty - has been reported since his arrest at the isolated Forward Operating Base Hammer, near Baghdad, in May 2010. More sensational was the revelation at his pretrial hearing at the Fort Meade military complex in Maryland of just how much the military knew about his problems - and virtually ignored. As a schoolboy in the US and in Wales, Manning would be seized by fits of rage and slam books on desks if he was misunderstood or if he was teased as a geek or a gay. As a teenager, he was treated for depression; he pulled a knife on his stepmother; and one of his first intimate relationships was with a drag queen. Within a month of signing up with the US Army in October 2007, he was deemed a ''liability'' by superiors and assigned to a ''discharge unit'' - one step short of being thrown out. Before deploying to Iraq he punched a female officer in the face and was sent to counselling for talking about his intelligence work and training in a YouTube video. He was psychiatrically assessed several times but was allowed to remain in the service, apparently because of his computer skills. ''That mess of a child,'' was how an army officer involved in the case described Manning to The Guardian, before adding: ''No one has mentioned the army's failure here.'' Shortly after arriving at FOB Hammer, the bolt was removed from Manning's weapon on the grounds that he was a risk to himself and others. His superiors complained of his ''dissociative behaviour'' - body in one place, mind in another - while he sought online counselling on a gender transition. While being counselled in Baghdad for bad behaviour, he flipped a table, dumping a computer on the floor and was restrained in a ''full nelson'' as he ''went for a weapons rack''.

Manning had emailed a superior, complaining of his ''gender identity disorder'' - attaching a photograph of himself dressed as a woman. But the recipient did not act on the email until after Manning's arrest. Warnings that his outbursts and ''elevated levels of paranoia'' warranted the withdrawal of his security clearance were ignored. Manning was so insecure that when picked on by army colleagues he would wet his pants, and in the weeks before his arrest he stabbed a chair with a knife and later was found hiding in a storeroom, in the foetal position. Only then was he booked and told he was to be discharged - on the grounds he had an ''adjustment disorder''. How could security at FOB Hammer be so lax that Manning and his colleagues could leave secret military passwords on notes near their computers in what was described as a ''security free-for-all'' where the Pentagon and State Department's classified intelligence network was used as an entertainment system for music, films and casual viewing of intelligence and military video footage? How was it that his months of rummaging through the global archives, and his copying of a quarter of a million documents that had nothing to do with his work in Iraq went undetected? ''As vulnerable as all f---,'' Manning wrote of the system's security.

Arguing that ''the whole need to know'' principle had been compromised by demands for greater intelligence sharing between US agencies in the wake of the September 11 attacks on the US, former CIA analyst Raymond McGovern likened the Manning case to that of Abu Ghraib, in which only junior service members were held to account for the torture of Iraqi prisoners. ''In today's army people are told they can do things - if they get caught, the officers will be defended; if they are from the bottom of the barrel they get told they are rotten apples,'' he said. Ann Wright, a former army colonel and a member of the US Foreign Service, sees the Manning case as further proof of ''the whole system breaking down''. ''In my experience he would have been withdrawn from a sensitive post,'' she said. ''As a senior Foreign Service officer and acting or deputy ambassador in four different posts, I never had access to the unpardonable amount of data that that kid had in his wooden shack in nowhere in Iraq - the system has failed miserably.'' Both McGovern and Wright have joined a Manning support group.

Following a week-long pre-trial hearing, army investigating officer Lieutenant Colonel Paul Almanza late last week recommended that Manning face a court martial on all 23 charges that he faces. The court martial recommendation must be formally accepted at the Pentagon before a hearing date is set.