Updated

Army Sgt. Bowe Bergdahl unexpectedly took the stand at his sentencing hearing Monday -- and choked up several times as he apologized to service members who were wounded in the years-long hunt to save him.

"I would like everyone who searched for me to know it was never my intention for anyone to be hurt, and I never expected that to happen," he said during the hearing at Fort Bragg in North Carolina. "My words alone can't take away their pain."

He was the first witness for the defense, who hadn't previously made it known that Bergdahl would address the court. It was his most extensive remarks in court yet.

Asked by a defense attorney what the worst part of captivity was, he responded that it wasn't the beatings. "The worst was the constant, just the constant deterioration of everything. The constant pain from my body falling apart. The constant screams from my mind," he said. "It was the years of waiting to see whether or not the next time someone opens the door if that would be the person coming to execute you."

He gave an unsworn statement, meaning that the judge will consider it but Bergdahl won't be cross-examined by the prosecutors.

Earlier, the wife of a soldier who was shot in the head during a search mission Bergdahl in Afghanistan delivered emotional testimony, tearing up as she described him as no longer being able to play with her children and how they “can't even hold hands anymore.”

Shannon Allen, the final witness for the prosecutors, said National Guard Master Sgt. Mark Allen is unable to speak, uses a wheelchair and needs help with everyday tasks.

"He's not able to reach out for her or talk to her," she said, pausing to take a deep breath as she referred to the brain injury's effect on his interactions with their daughter, who was an infant when he was wounded in 2009 after being ambushed by insurgents. She is now 9 and Mark Allen is in his mid-30s. "He's never had the chance to really play with her or help coach her sports or ask about her day."

Bergdahl faces a maximum sentence of life in prison after pleading guilty to desertion and misbehavior before the enemy. He was held by Taliban allies for five years after he left his remote post in Afghanistan in 2009.

Before the injury, Allen's husband was an outdoorsman who was "very loud and outgoing," she said. He loved playing outside with his son from a previous relationship.

ARMY SGT. BOWE BERGDAHL: WHO IS HE?

Mark Allen's wife said he can smile, make eye contact and sometimes make a thumbs up, but he has little communication beyond that. Prosecutors showed a video of Shannon Allen and a home care nurse going through their routine of rolling his limp body into a sling to get him out of bed and into a wheelchair each day.

"He lost me as a wife, essentially, because instead of being his wife I am his caregiver," she said. "I mean, we can't even hold hands anymore."

Bergdahl, a 31-year-old soldier from Hailey, Idaho, made no deal with prosecutors to limit his punishment, so the judge has wide leeway to determine his sentence.

Bergdahl said he tried to escape more than a dozen times from his Taliban captors -- where he was caged, kept in the darkness and beaten -- before President Barack Obama brought him home in 2014 in a swap for five Taliban prisoners at Guantanamo Bay.

The judge in the sentencing hearing, Army Col. Jeffery Nance, also ruled Monday that President Trump's scathing criticism of Bergdahl won't prevent the soldier from receiving a fair sentence.

BERGDAHL SENTENCING: NAVY SEAL BREAKS DOWN WHILE DESCRIBING DEATH OF MILITARY DOG

Nance said the court has not been directly affected by Trump's remarks, nor would the comments cause a reasonable member of the public to have doubts about the fairness of the military justice system. He had to consider both questions in deciding on whether actual or apparent unlawful command influence was interfering in the case.

"I am completely unaffected by any opinions President Trump may have about Sgt. Bergdahl," the judge said. He added that prosecutors had convinced him that the Trump comments won't put "an intolerable strain" on the public perception of military courts.

Then-Republican nominee Trump repeatedly called Bergdahl a traitor on the campaign trial and suggested that he be shot or thrown from a plane without a parachute. Trump revived those comments when Bergdahl pleaded guilty on Oct. 16 by saying at a news conference that he thinks people are aware of what he said before.

The White House later released a statement that, while not mentioning Bergdahl by name, said that every military justice case should be decided by military personnel using their own judgment. Nance cited that statement in his ruling.

Nance did say he would keep Trump's comments in mind as he weighs other factors that will go into his sentencing decision. The hearing is expected to last several more days.

Those mitigating factors, such as Bergdahl's mental health or his time in captivity by Taliban allies, would encourage leniency. On the other hand, prosecutors are presenting evidence of wounds to several service members who searched for Bergdahl as aggravating evidence to push for a stiff punishment.

The Associated Press contributed to this report.