Fort Bragg, North Carolina (CNN) Army Sgt. Bowe Bergdahl teared up at his sentencing on Monday as he apologized to service members who searched for him after he deserted his outpost in Afghanistan in 2009.

"My words can't take away what people have been through," Bergdahl, 31, told an audience at his court martial that spilled into an overflow room. "I am admitting I made a horrible mistake."

Bergdahl pleaded guilty October 16 to desertion and misbehavior before the enemy. His lengthy testimony began after the presiding judge rejected his attorneys' request to dismiss the case over President Trump's criticism of him during his campaign for the White House.

He was captured by the Taliban hours after he walked off his post. At the sentencing hearing, soldiers who looked for Bergdahl have described the grueling, dangerous conditions they endured. Last week, one former Navy SEAL sobbed on the stand as he described the firefight in which his K-9 partner was killed.

Bergdahl said when he initially left his post, "I was trying to help and knowing it didn't breaks my heart," he said. "It was never my intention for anyone to be hurt."

Bergdahl said he made several attempts to escape his captors, each leading to conditions worse than those he tried to escape. During one escape attempt, he fell off a cliff and injured his hip and shoulder so badly it still hurts him, he said. He ate grass until he got sick and spent days looking for water.

When they found him, Taliban soldiers ripped out his beard and hair and kicked and spat on him. When he returned to captivity, they put him in a cage with his legs and arms shackled. He spent four years in there.

Physical and emotional torture

Bergdahl was released in a controversial prisoner swap in May 2014 for five Guantanamo Bay detainees. He faces up to life in prison for his desertion.

After his apology, he focused his testimony on details of day-to-day life in captivity, describing a squalid cycle of illness, pain and torture.

He went months without bathing or cleaning, he said. He developed sores on his wrists, ankles and head from his shackles and a blindfold. Temporary relief came from using a razor to cut open his sores to drain, he said. At one point, the Taliban used scissors to cut the dead flesh off his ankles and feet.

He had diarrhea for most of time, and for the first year in the cage he sat in soiled clothing. His condition improved when his captors started serving him boiled water and his cage was raised so they could put a latrine under it for him to use.

Worse than the physical pain was the psychological torture, he said. His captors showed him DVDs and videos on their cellphones of executions, he said. They told him they would cut his head off and point AK-47s at his temple.

"The worst was the constant deterioration of everything, pain from my body falling apart, internal screams from my mind, the darkness and light," he said. "I was wondering if every time the door opened it would be the person coming to execute you."

A father becomes helpless

His turn on the stand came after testimony from the wife of a soldier who was shot in the head while searching for Bergdahl.

Shannon Allen, the wife of Master Sgt. Mark Allen, described the impact of the injury on her husband and his family. She was among witnesses for the prosecution who testified to the impact of Bergdahl's desertion on soldiers sent to find him.

Allen teared up on the stand as she described her husband's present condition.

Shannon Allen says her husband cannot be left alone.

Before his injury, Allen was a happy-go-lucky involved father who coached children's sports, his wife said. He loved the military and loved music.

Since the incident, he's had about 20 surgeries, she said. He needs scores of medicines, vitamins and supplies and requires nursing care 24 hours a day.

Bergdahl watched intently as the prosecution played a video of Shannon Allen and a nurse helping her husband get out of bed and maneuver through the home, which is filled with specialty medical equipment.

As with an infant, Mark Allen cannot be left alone because he might have seizures, she said. He cannot eat or drink by mouth and groans with pain.

His young daughter, Journey, crawls onto his wheelchair and plays on him because he cannot pick her up or hold her, Shannon Allen said.

"He is present, makes eye contact," she said. "He can laugh, smile, cry. That is the extent of the communication."

A Veterans Administration doctor testified Monday by telephone about Allen's condition. His eyes are open but there is no awareness of his environment, Dr. Rafael Mascarinas said. Part of Allen's brain was removed to relieve pressure -- the part that controls thinking, speaking and voluntary movement, Mascarinas said. Allen is between 90% and 100% paralyzed.

The hearing is expected to resume Tuesday, possibly with more testimony from Bergdahl.