Nov. 3 (UPI) — Army Sgt. Bowe Bergdahl will receive a dishonorable discharge for desertion in Afghanistan but no prison time, a military judge ruled Friday.

Bergdahl was convicted of desertion and endangering fellow troops when he left his post in Afghanistan in 2009 and was captured by the Taliban. He was returned to U.S. custody in 2014 in a prisoner swap.

At the Fort Bragg, N.C., sentencing hearing on Friday, Col. Judge Jeffrey Nance added that Bergdahl must forfeit $10,000 in pay and will be reduced in rank to private.

The ruling followed a two-week sentencing procedure that included testimony from several of Bergdahl’s comrades. He pleaded guilty to the charges on Oct. 16, admitting guilt without prosecution assurances regarding his sentence. On Monday he apologized to those soldiers injured while attempting to rescue him. He also described the conditions under which he was kept by the Taliban, noting he was caged for four of the five years he was held.

Nance did not offer an explanation on Friday for the sentence, which will be reviewed by Gen. Robert Abrams, who convened Bergdahl’s court martial. It can also be reviewed by the U.S. Army Court of Criminal Appeals.

The preliminary hearing officer’s recommendation of leniency in 2014 prompted a warning from Sen. John McCain, R-Ariz., that he would hold a hearing if Bergdahl was not punished. The case was prominently mentioned in campaign speeches by President Donald Trump, who regularly called Bergdahl a “dirty rotten traitor” who deserved execution. Following Trump’s inauguration, Eugene Fidell, who led Bergdahl’s defense team, suggested a fair trial was impossible after Trump’s comments.

Nance called Trump’s remarks “disturbing” but allowed the case to proceed.