Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

FORT BRAGG, N.C. — Several soldiers were seriously injured in the search for Sgt. Bowe Bergdahl, including a sergeant who was shot in the head, an Air Force intelligence officer testified Thursday in the sentencing phase of Bergdahl's desertion trial.

The officer, Lt. Col. John Marx said he was leading a team of Americans and members of the Afghan Army in July 2009 through two villages searching for Bergdahl, who had abandoned his post, when they were ambushed by insurgents from "all sides."

"That's when all hell broke loose," Marx said.

About six feet from him, he said, Sgt. 1st Class Mark Allen was shot through the head, with the bullet entering and exiting his temples. "I thought he might be dead," Marx said.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Allen, a member of the Georgia Army National Guard, was airlifted to safety, but now uses a wheelchair and cannot speak. He was not in court on Thursday.

Bergdahl, 31, pleaded guilty last week to desertion and misbehavior before the enemy. He claims he was trying to bring attention to misconduct in his unit when he wandered off and was captured by the Taliban, who held him for five years. Prosecutors want to prove that his desertion endangered those who went looking for him.

Related: Bowe Bergdahl Case Up in the Air as Sentencing Resumes

The military judge in the case, Col. Jeffery R. Nance, could sentence Bergdahl to prison for life.

In addition to Marx, Nance heard from three other witnesses, including Spc. Jonathan Morita, whose hand and elbow were hit by two rocket-propelled grenades during the same mission that injured Allen.

"I just thought I was going to definitely die right there in Afghanistan," Morita said. "I accepted my fate. Picked up my Bible, read it, picked up a rifle and started firing again."

Morita said he can't write or eat with his right hand and can't clean himself properly in the bathroom. As he left the courtroom, Morita cast a dirty look in Bergdahl's direction.

Bergdahl was tortured and often held in solitary confinement during his five years in Taliban captivity. He was released in 2014 in a prisoner swap by President Barack Obama, which was criticized by Trump and the Republicans.

While running for president, Trump disparaged Bergdahl as a "dirty rotten traitor" — words which could jeopardize the entire case. Nance temporarily halted the sentencing hearing on Monday after seeing a video of Trump on Oct. 16 referring to the comments he made on the campaign trail.

The sentencing hearing is scheduled to resume on Monday.