FORT BRAGG, N.C. (Reuters) - U.S. Army Sergeant Bowe Bergdahl on Friday was spared prison for endangering his comrades in arms when he deserted in Afghanistan in 2009, a sentence swiftly condemned by President Donald Trump, who while seeking election had called for his execution.

“The decision on Sergeant Bergdahl is a complete and total disgrace to our Country and to our Military,” Trump posted on Twitter from Air Force One as he flew to Asia at the start of a lengthy tour of the region.

A military judge recommended that Bergdahl should be dishonorably discharged from the service, demoted to private and forfeit $10,000 in pay. Army Colonel Jeffery Nance took less than a minute to render his decision and made no other comment.

Bergdahl was captured eight years ago by the Taliban after walking off his combat outpost. He endured torture and malnutrition while held prisoner by the insurgent group for nearly five years. His case sparked a national debate over whether he was a victim or a villain.

The soldier, who had pleaded guilty to desertion and misbehavior before the enemy, faced a maximum term of life in prison.

Late Friday morning, the 31-year-old Hailey, Idaho, native trembled as he waited to hear his punishment in a courtroom in Fort Bragg, North Carolina.

Defense lawyers, who had urged Nance to show leniency, said after sentencing that Bergdahl was relieved and eager to move on, though they would not discuss his plans. Bergdahl has remained on active duty at Fort Sam Houston in San Antonio, Texas.

“This has been a terrible ordeal,” said one of his lawyers, Eugene Fidell.

Neither Bergdahl nor prosecutors, who had sought a 14-year prison term, commented.

Slideshow ( 3 images )

Soldiers who testified about the hardships and injuries suffered in the hunt for Bergdahl after he walked off his post in Paktika province in June 2009 without permission said they were disappointed by the sentence.

“It’s definitely a slap in the face,” former Army Specialist Jonathan Morita said in a phone interview. Morita’s right hand was mangled by a rocket-propelled grenade during a July 2009 raid seeking intelligence on Bergdahl’s whereabouts.

Along with criticism over the years from U.S. political leaders and fellow soldiers over the dangerous searches prompted by Bergdahl’s actions, the conditions of his release sparked controversy.

In May 2014, Bergdahl was handed over to U.S. special operations troops in Afghanistan in exchange for five Taliban detainees, who were released from the Guantanamo Bay prison and flown to Qatar.

Last year, as a Republican presidential candidate, Trump called Bergdahl “a no-good traitor who should have been executed.”

Responding to a defense motion on Trump’s comments, Colonel Nance ruled they had not influenced him nor affected Bergdahl’s chances of a fair sentence. However, the judge said he would consider them a mitigating factor.

Defense attorney Fidell said on Friday that Americans should be offended by Trump’s behavior.

“President Trump’s unprincipled effort to stoke a lynch-mob atmosphere while seeking our nation’s highest office has cast a dark cloud over the case,” he said.

Slideshow ( 3 images )

A dishonorable discharge, issued for the most serious offenses, cuts off all military and veterans benefits, including healthcare from the Department of Veterans Affairs.

That could pose difficulties for Bergdahl, who, according to testimony, suffered significant nerve damage while a Taliban prisoner and has several mental health conditions.

His punishment must be approved by the commanding general of the U.S. Army Forces Command and then will automatically be reviewed on appeal. The discharge will not take effect until an appellate court affirms Bergdahl’s conviction and sentence.

Two portraits of Bergdahl emerged during the sentencing proceedings.

Defense lawyers said he was a young, hardworking soldier who did not understand the full consequences of his actions when he left to report what he said were problems in his unit.

Bergdahl apologized in court this week for the pain he caused fellow service members and admitted he had made “a horrible mistake.”

But prosecutors said Bergdahl knew he would trigger alarm in the war zone. They acknowledged he suffered during his years as a Taliban prisoner, but argued it resulted from his choices and did not diminish the harm he caused others.

Retired Army Lieutenant Colonel Jeffrey Addicott said he was surprised by the judge’s decision.

“You had several members of our military who have been maimed for the rest of their life because of what Bergdahl did, so he should have received jail time, in my opinion,” said Addicott, now a law professor at St. Mary’s University in San Antonio, Texas.