A retired Navy SEAL wounded in the search for U.S. Army Sergeant Bowe Bergdahl, who walked away from his post in Afghanistan in 2009, testified about the harrowing firefight that ended his career.

Speaking at Bergdahl’s sentencing hearing Wednesday, Senior Chief Petty Officer James Hatch choked up when describing how enemy combatants shot a trained dog that was with the team before shooting him just above his right knee.

“I really thought that I was going to die,” Hatch said.

Former Navy SEAL James Hatch, shot in the leg during a July 2009 attempt to rescue U.S. Army Sergeant Bowe Bergdahl in Afghanistan, arrives with his service dog at the courthouse to testify on the second day of Bergdahl's sentencing proceedings at Fort Bragg, N.C., Oct. 25, 2017.

Hatch walks with a limp after undergoing 18 surgeries to repair his leg.

The former Navy SEAL, forced to retire from the military after nearly 26 years of service because of injuries sustained while searching for Bergdahl, said he had known days before that the search was going to be hazardous.

“Somebody’s going to get killed or hurt trying to get that kid,” he recalled saying to his teammates.

Trump motion still pending

The hearing started with a surprise, as the judge, Colonel Jeffery R. Nance, said he was not yet ready to rule on the defense’s argument that recent comments by President Donald Trump had made a fair hearing impossible.

“I’m still considering it,” Nance said.

The defense has argued that the president seemed to endorse previous assertions, made when he was a presidential candidate, that Bergdahl was a traitor and deserved execution. As commander in chief, he is the superior officer of all the military officials responsible for disciplining Bergdahl.

Questioned by reporters last week about Bergdahl, Trump said he couldn’t say more on the case, “but I think people have heard my comments in the past.”

Last week, Bergdahl pleaded guilty at a court-martial hearing to charges of desertion and misbehavior before the enemy. The latter carries a maximum sentence of life in prison.