Media playback is unsupported on your device Media caption The BBC's David Willis at Fort Meade: "Bradley Manning addressed his remarks directly to the judge and at times appeared on the verge of tears"

Pte First Class Bradley Manning has apologised for hurting the US by leaking a trove of classified US government documents to Wikileaks.

At a sentencing hearing in Fort Meade, Maryland, Pte Manning, 25, said he had mistakenly believed he could "change the world for the better".

And he said that in retrospect, he should have worked "inside the system".

Pte Manning, 25, faces up to 90 years in prison following his conviction in July on espionage and other charges.

In an unsworn statement at the hearing in the sentencing phase of his court martial, Pte Manning said: "I'm sorry that my actions hurt people. I'm sorry that it hurt the United States.

'Learning experience'

"I'm apologising for the unexpected results of my actions. The last three years have been a learning experience for me."

At the scene Pte Manning carried several stapled sheets of paper as he stood abruptly from his seat and walked in a jerky manner - like a puppet, with strings attached - across the room to a chair where he could look directly at the judge. It was the first time he had spoken since a pre-trial hearing. His voice was earnest, and he tried to convey a sense of remorse to the judge. He described himself as a junior soldier and asked, "How on Earth could I… think I could have changed the world?" It was a prepared script, and he had a hard time delivering it. His hands were shaking so much that he could not hold the paper still. He swallowed hard, trying to maintain his composure. The judge did not ask questions. As he spoke, her eyes flickered over to a screen on her desk.

Last month, military Judge Col Denise Lind convicted Pte Manning of 20 charges including espionage, theft and violating computer regulations.

He had already admitted passing hundreds of thousands of battlefield reports and diplomatic cables to Wikileaks while stationed in Iraq in 2010, saying in a pre-trial hearing he had leaked the secret files in order to spark a public debate about US foreign policy and the military.

In his brief statement on Wednesday, Pte Manning said he had come to realise he should have worked "more aggressively inside the system" to make the changes he sought.

"When I made these decisions I believed I was going to help people, not hurt people," he said.

"Unfortunately, I can't go back and change things."

Pte Manning also said he understood he must "pay a price" for his actions, but hoped one day to go to university and have a meaningful relationship with his sister and other family members.

The sentencing phase of the trial has focused on how much damage the Wikileaks revelations caused. The prosecution has called witnesses who described the impact on US diplomatic relations and on the military's dealings with Afghan civilians, among other effects.

Romantic 'rough patch'

Pte Manning has said he never intended to harm US national security.

Image caption Pte Manning emailed his military therapist this photo with a letter describing his issues with gender identity, entitled My Problem

Meanwhile, on Wednesday the organisation that received and published the leaked documents, Wikileaks, said the statement was "extorted from him under the overbearing weight of the United States military justice system".

"Mr Manning's forced decision to apologise to the US government in the hope of shaving a decade or more off his sentence must be regarded with compassion and understanding," the anti-secrecy group said.

Ahead of Pte Manning's statement, Navy Capt David Moulton, a psychiatrist, testified that at the time of the leak Pte Manning felt abandoned by friends and family and had hit a rough patch with his boyfriend amid an isolating deployment.

The psychiatrist interviewed Pte Manning for 21 hours after his arrest.

'Gender disturbance'

Pte Manning had also decided he wanted to become a woman, Capt Moulton said.

He underestimated how much trouble he would get in, for sure David Moulton, Military psychiatrist

In psychiatric terms, Pte Manning has a "gender identity disorder", or "disturbance of one's gender", Capt Moulton said.

This is different from being gay, he added.

"Gender is very much at the core of our identity," he said, adding that when a person is uncertain about his or her gender, the whole world seems "off-keel".

Pte Manning referred to these issues in his statement, saying they were "ongoing" and "a considerable difficulty in my life", but adding that they were no excuse for his actions.

Amid this turmoil, Pte Manning also became disillusioned about the US War in Iraq and was trying to correct "injustices", Capt Moulton said.

"Manning was under the impression that the leaked information was going to change how the world saw the war in Iraq," the psychiatrist testified.

He added that Pte Manning believed the leaks would ultimately end all war, and the young soldier was unclear about the extent of the punishment he would face for his actions.

Image caption Manning supporters delivered 100,000 signatures in Norway for him to get the Nobel Peace Prize

"He underestimated how much trouble he would get in, for sure," Capt Moulton said.

"He was really relying on his morals and his ideology and not thinking beyond that."

Separately, an Army psychotherapist who treated Pte Manning while he was in Iraq said he had begun the process to remove him from the military.

"He was having issues at work," Capt Michael Worsley said, adding Pte Manning's job as an intelligence analyst had made him even more isolated and anxious.

During treatment, the soldier sent Capt Worsley an email describing his desire to become a woman and his hopes military life would "get rid of it", attaching a photo of himself with a blond wig and makeup.

Pte Manning's sister and aunt are also on the list of potential defence witnesses.