FORT BRAGG, N.C. — A military judge has found that Bowe Bergdahl should serve no prison time for endangering his comrades by walking off his Afghanistan post.

The judge also gave Bergdahl a dishonorable discharge, reduced his rank to private and said he must forfeit pay equal to $1,000 per month for 10 months. The judge made no other comments.

Bergdahl appeared tense, grimaced and clenched his jaw. His attorneys put their arms around him and one patted him on the back.

Bergdahl pleaded guilty to desertion and misbehavior before the enemy and had faced up to life in prison. The judge had wide leeway because Bergdahl made no deal with prosecutors to limit his sentence.

Prosecutors had sought stiff punishment because of wounds to service members who searched for Bergdahl after he disappeared in 2009. He was held captive by Taliban allies for five years.

The defense sought to counter that evidence with testimony about Bergdahl’s suffering during five years as a captive of Taliban allies, his contributions to military intelligence and survival instruction and his mental health problems.