A military judge has ruled that Bowe Bergdahl, who has pleaded guilty to charges of desertion and misbehavior before the enemy, should serve no prison time.

During a sentencing hearing Friday, Bergdahl was sentenced to dishonorable discharge, loss of pay and benefits, and reduction in rank from sergeant to private, NPR’s Frank Morris reported from the court in Fort Bragg, N.C.

The judge, Col. Jeffery Nance, had wide discretion in determining a sentence for Bergdahl, who walked off his military post in Afghanistan in 2009 and was held by the Taliban for five years. He could have given him anything from no prison time to life in prison.

Prosecutors had been seeking 14 years in prison, while defense lawyers had asked for no prison time and a dishonorable or bad conduct discharge.

The military court heard testimony about three soldiers who were wounded while searching for Bergdahl.

Copyright 2017 NPR. To see more, visit http://www.npr.org/.