A prison officer guarding the soldier accused of giving classified documents to WikiLeaks made jokes about him being ordered to remove his underwear because he was a suicide risk, a pre-trial hearing was told.

On the second day of the hearing, a Maryland courthouse heard that Private First Class Bradley Manning had his underwear confiscated at night because he told a prison guard that if he wanted to kill himself, he could hang himself with the waistband.

Officers testified that they regarded it as a suicidal comment when the 24-year-old said: "I have everything I need right here to be able to harm myself. The waistband of my underwear can do this."

But Manning's lawyer - who is seeking dismissal of all charges on the grounds that his imprisonment at the Marine brig in Quantico, Virginia, amounted to illegal punishment - suggested he was commenting on the absurdity of his situation.

Manning, who made his first public appearance in over two years at the courthouse on Tuesday, took the witness stand on Thursday, stuttering over his words as he as he tried to answer questions about his arrest in Iraq in May 2010.

David Coombs, defending, revealed on Wednesday that the chief legal officer at Quantico at the time, Lieutenant Colonel Christopher Greer, made light of the underwear episode in an email, composing a rhyme in the style of the popular Dr Seuss books.

The message said: "I can wear them in a box. I can wear them with a fox. I can wear them in the day. I can wear them so I say. But I can't wear them at night. My comments gave the staff a fright."

Marine Colonel Robert Oltman, the officer in charge of security in the brig, responded to the email with the signature, "Sam I am," another Dr Seuss reference.

During his court testimony, Mr Coombs asked the security chief if it was "funny to you that Pfc Manning was being stripped at night?"

Image Caption:Manning's supporters protesting during the hearing

"No, it was not, it was a very serious issue," Col Oltman replied.

The court heard that Manning was kept under strict conditions partly because a previous prisoner had committed suicide and despite the fact that psychiatrists who examined him at Quantico repeatedly recommended that his conditions be eased.

The suicide watch confinement also came after Manning was seen engaged in "erratic dancing" and licking the bars in his cell, the court martial was told.

The informant was held at Quantico for nine months, from July 2010 to April 2011, when he was moved to Fort Leavenworth, Kansas.

Throughout his time at Quantico, he was designated a "maximum custody" detainee and considered at risk of either suicide or harming himself or others.

He was locked up alone for at least 23 hours a day, forced to sleep naked for several nights and required to stand naked at attention one morning, his lawyers assert.

Manning now argues that all charges should be dropped due to what he calls his "needlessly harsh treatment" during his nine months of confinement in Quantico.

He is accused of sending hundreds of thousands of classified Iraq and Afghanistan war logs and more than 250,000 diplomatic cables to WikiLeaks while he was working as an intelligence analyst in Baghdad in 2009 and 2010.

The soldier faces possible life imprisonment if convicted of aiding the enemy, the most serious of the 22 charges that he faces.