A military judge on Nov. 3 ruled that Army Sgt. Bowe Bergdahl will receive a dishonorable discharge and a reduction in rank to private but will not face prison time for deserting his post in Afghanistan in June 2009, the Associated Press reports.

Bergdahl, who was held captive for five years by the Taliban — during which time he says he was tortured and beaten — after abandoning his unit’s outpost near the town of Yahya Kheyl in Afghanistan’s Paktika province, plead guilty on Oct. 17 to the charges of desertion and misbehavior before the enemy.

Bergdahl was released from Taliban captivity in May 2014 after a controversial prisoner exchange involving five Guantanamo Bay detainees. Bergdahl opted to be tried by a military judge instead of a jury, CNN reports.

Initially faced with the possibility of life in prison, the prosecution asked the presiding judge, Army Col. Jeffery R. Nance, for a 14-year sentence and a dishonorable discharge, CNN reports.

Bergdahl will lose all veterans benefits and will be required to pay a fine of $1,000 a month for 10 months, according to The Washington Post.

Bergdahl’s defense attested that the soldier “probably should not have been in the Army,” Capt. Nina Banks, a military attorney for Bergdahl said in her closing argument.

The prosecution argued that Bergdahl was aware of the risks when he deserted and that his decision to walk off post placed Army personnel sent to search for him in danger.

Soldiers tasked with searching for Bergdahl were called upon to testify during the proceedings, and one of the witnesses, retired Navy SEAL James Hatch testified that he and his military working dog came under fire while searching for Bergdahl, CNN reports. Hatch was shot in the leg, and his  working dog was shot and killed.

“I thought I was dead,” he said.

WATCH NEXT: