US Army Sergeant Bowe Bergdahl has been spared prison time for endangering fellow troops when he deserted his post in Afghanistan in 2009, but a military judge ordered he should be dishonourably discharged from the service.
Bergdahl was captured by the Taliban and spent five years under brutal captivity by the insurgent group. He had faced up to life in prison after pleading guilty to desertion and misbehaviour before the enemy.
The 31-year-old trembled on Friday (local time) in a military courtroom at Fort Bragg in North Carolina as he waited to hear his punishment.
Army Colonel Jeffery Nance delivered the sentence in a hearing that lasted just two minutes. He also recommended Bergdahl be demoted to private.
Prosecutors had asked Nance to send Bergdahl to prison for 14 years for the hardships and injuries endured by service members who searched for the soldier after he left his combat outpost in Paktika province in June 2009 without permission.
Defence lawyers had said Bergdahl, who experts testified has several mental health conditions, should not go to prison.
A dishonourable discharge, given for the most serious offences, typically means a loss of all veteran and military benefits.
Bergdahl's case made him a polarising figure. He drew withering criticism from political leaders in Washington and fellow soldiers, both for the dangerous efforts to find him and the 2014 Taliban prisoner swap brokered by the Democratic Obama administration that secured his release.
During his successful campaign for the presidency last year, Republican Donald Trump called Bergdahl "a no-good traitor who should have been executed". He called the decision a "complete and total disgrace".
His case was the subject of season two of hit podcast Serial.
Defence lawyers argued at Bergdahl's sentencing hearing that he was a young, hardworking soldier who did not understand the full consequences of his actions when he deserted.
Bergdahl, who has said he wanted to report problems in his unit, apologised in court this week for the suffering he caused his comrades and admitted he had made "a horrible mistake".
Prosecutors, however, said Bergdahl knew his disappearance would trigger alarm in the war zone.
Prosecutors acknowledged that Bergdahl suffered during his years as a prisoner of the Taliban, but argued that did not diminish the pain of fellow service members who were injured during the futile hunt for him.