Pfc. Bradley Manning was a deeply troubled soldier struggling with issues of gender identity whose alleged leaking of classified material to WikiLeaks could have been prevented by superiors.

He was also a gifted intelligence analyst who had received extensive training in proper handling of classified information and had been reprimanded once for breaching the rules.

Those were the clashing portraits of the same young man drawn by the defense and prosecution on the first full day of testimony in a hearing room at Maryland’s Fort Meade to decide whether Manning, who spent his 24th birthday in court, should face a court-martial for the alleged leak.

Manning, a former analyst in Baghdad, was detained in May 2010 and could face the death penalty or life in prison if he is tried and found guilty of all 22 counts of violating military code with which he is charged.

Under cross-examination, a series of government witnesses acknowledged lapses by Manning’s superiors, including a failure to pull his security clearance and deny him access to the classified computers from which he is alleged to have leaked information.

In April, Manning sent an e-mail to a superior, Master Sgt. Paul D. Adkins, saying that he was suffering from a gender identity disorder. He included a picture of himself dressed as a woman and described how it had affected his ability to do his job, to interact with others and to “think,” according to Capt. Steven Lim, military intelligence officer in the 1st Army East Division at Fort Meade.

But Adkins did not share that e-mail with Lim until after Manning was arrested, Lim acknowledged.

Manning also had a Facebook page under the name of Breanna Manning and two e-mail addresses that corresponded to that name, said retired Sgt. 1st Class Troy Bettencourt, an Army investigator in the case.

Bettencourt said he knew that Manning was gay, and that he exhibited “odd” behavior. Manning had been punished for assaulting a supervisor, Bettencourt added, and at one point was found in a room “curled up in a ball.”

Adkins apparently knew that Manning was unstable even before Manning was deployed to Iraq in fall 2009, but did not recommend that he stay behind because the Army was short on intelligence analysts. In December 2009, Manning became “furious” during a counseling session in Baghdad, flipped over a table, damaged a government computer and had to be restrained, and then “went for a weapons rack,” defense attorney David E. Coombs said.

“Would you consider this a minor incident?” Coombs asked Lim.

“Probably not,” said Lim, who was the head of Manning’s military intelligence section in Baghdad with the 2nd Brigade, 10th Mountain Division.

Lim acknowledged that such behavior could have resulted in a “derogatory” report in Manning’s file resulting in the pulling of his security clearance.

By airing superiors’ failure to address Manning’s personal issues, the defense team is “trying to discover all the failures of the chain of command which would help them in setting up the mitigation argument for the sentencing portion of the proceeding,” said David D. Velloney, a military law expert at Regent University School of Law. But they probably would not suffice to beat the charges, Velloney said. Those charges include aiding the enemy and violating the Espionage Act by wrongfully causing U.S. intelligence to be published on the Internet.

Coombs is also likely “continuing his shots across the bow in an effort to influence the government to soften its position on the seriousness of the charges against Manning,” Velloney said.

As an all-source intelligence analyst, Manning received 16 weeks of advanced intelligence training at Fort Huachuca in Arizona, said retired Sgt. 1st Class Brian Madrid, who was one of his instructors. While there, however, Manning posted a video on YouTube talking about his daily life at Huachuca, including “using buzzwords such as classified, top secret,” Madrid said. Manning was given “corrective training,” including doing an oral report for his company on information security.

The hearing also uncovered previously unknown details in the case.

Special Agent Mark Mander with the Army’s Criminal Investigation Division said that Adrian Lamo, a convicted hacker whose online chats with Manning led investigators to Manning, led investigators to a former Energy Department employee who Lamo said helped WikiLeaks decrypt a military video provided by Manning.

The employee, Jason Katz, was fired from Brookhaven National Labs in March 2010 for “inappropriate computer activity,” Mander said. The video, of an airstrike on an Afghan village that killed dozens of civilians, has not been posted by WikiLeaks.

Mander also said that Manning’s aunt, Debra Van Alstyne, told him that Manning had contacted her while he was in Iraq to ask her how WikiLeaks’ release of a 2007 Army video showing an Apache helicopter firing on civilians was “being perceived in the United States.” After Manning was detained, he again contacted her and asked her to post a reference on his Facebook page to the Apache video, Mander said.

Mander said that when investigators made a second visit to Van Alstyne’s home in Potomac, where Manning had lived before joining the Army, they recovered a memory card containing classified information and other digital media.

In the audience were two attorneys for WikiLeaks and its founder, Julian Assange. A federal grand jury is investigating Assange’s role in the leaks, and on Friday, Coombs suggested that the Justice Department has an interest in obtaining a plea bargain in the Manning case and using Manning “as one of the many witnesses to go after Julian Assange.”

Jennifer Robinson, an attorney for WikiLeaks, said “it is very clear that the matters raised here in these proceedings have potential ramifications” for WikiLeaks and Assange, who is in London. “Our concerns,” she said, focus on “a potential extradition request for Mr. Assange.”

At one point, Coombs asked Bettencourt whether Manning’s military leadership had failed him.

“I would like to think if I were in the chain of command, I would have handled it differently and prevented him from deploying,” Bettencourt said. “But that is in hindsight.”