This is an archived article and the information in the article may be outdated. Please look at the time stamp on the story to see when it was last updated.

Bowe Bergdahl received a dishonorable discharge from the US Army but will avoid prison time for desertion and misbehavior before the enemy after abandoning his outpost in Afghanistan in 2009, a military judge ruled Friday.

U.S. Army Sgt. Robert Bowdrie 'Bowe' Bergdahll, 29 of Hailey, Idaho, leaves the Ft. Bragg military courthouse after a pretrial hearing on January 12, 2016 in Ft. Bragg, North Carolina. (Credit: Sara D. Davis/Getty Images)
U.S. Army Sgt. Robert Bowdrie ‘Bowe’ Bergdahl, 29 of Hailey, Idaho, leaves the Ft. Bragg military courthouse after a pretrial hearing on January 12, 2016 in Ft. Bragg, North Carolina. (Credit: Sara D. Davis/Getty Images)

The judge also ruled that Bergdahl’s rank be reduced from sergeant to private. Additionally, he will be required to pay a $1,000 fine from his salary for the next 10 months.

“Sgt. Bergdahl has looked forward to today for a long time,” Eugene Fidell, Bergdahl’s civilian attorney, said at a news conference after the sentence was announced.

“As everyone knows he was a captive of the Taliban for nearly five years, and three more years have elapsed while the legal process unfolded. He has lost nearly a decade of his life.”

The sentence is effective immediately, except for the dishonorable discharge, which Bergdahl is appealing, according to Fidell.

Bergdahl appeared visibly shaken as the sentence was announced, according to CNN affiliate WRAL. Two of his attorneys stood by his side with their hands on his back while the judge, Army Col. Jeffery R. Nance, read the sentence.

The Army soldier, whom the Taliban held for five years after he deserted his Afghanistan outpost, pleaded guilty last month to the charges.

Bergdahl was released in May 2014 in a controversial exchange for five Guantanamo Bay detainees.

He originally faced the possibility of life in prison, but the prosecution asked the judge for a 14-year sentence. Bergdahl’s attorneys asked Nance for a punishment of dishonorable discharge.

Bergdahl had chosen to be tried by a military judge instead of a jury.

Defense: Bergdahl ‘should not have been in the Army’

Bergdahl’s attorneys asked the judge for leniency during sentencing hearings, arguing he had a previously undiagnosed mental illness when he left his post.

“Hypothetically, he probably should not have been in the Army,” said Capt. Nina Banks, one of his military defense attorneys, in her closing argument.

Bergdahl suffered from numerous mental illnesses, including schizotypal personality disorder and post-traumatic stress disorder, according to Dr. Charles Morgan, a forensic psychiatrist and professor at the University of New Haven and Yale University. He testified for the defense Wednesday.

Morgan said Bergdahl was raised in a tense and sometimes scary household that contributed to social anxiety and cognitive defects that he was suffering from before he enlisted in the Army.

The defense also argued the information Bergdahl was able to provide upon his return — and his willingness to share that information and cooperate with investigators — warranted a more lenient sentence.

Prosecution: Bergdahl put soldiers in danger

But government prosecutors said Bergdahl was aware of the risks when he deserted, and that doing so put his fellow soldiers in danger.

Soldiers who searched for Bergdahl after he deserted were called to testify and shared stories of the grueling conditions they endured while looking for him.

One witness, Capt. John Billings, was Bergdahl’s platoon leader in Afghanistan. Billings said the platoon searched for the then-private first class for 19 days, going without food or water.

Retired Navy SEAL Chief Petty Officer James Hatch testified that he and his dog came under fire while looking for Bergdahl. He was shot in the leg, and his K-9 partner, Remco, was shot in the face and killed.

“I thought I was dead,” said Hatch, who now walks with a heavy limp after 18 surgeries. He said he was concerned because there was little time to plan the search for Bergdahl, and other soldiers knew he had willfully walked away.

When asked why he would go searching for Bergdahl, Hatch said, “He is an American.”

“He had a mom,” he added.

Bergdahl tearfully apologized this week to the service members who searched for him.

“My words can’t take away what people have been through,” he said. “I am admitting I made a horrible mistake.”

Lawyer: Trump’s remarks ‘preposterous’

Following the sentencing, President Donald Trump tweeted that the decision was a “complete and total disgrace to our Country and to our Military.”

Fidell denounced the President’s comments, saying “every American should be offended by his assault on the fair administration of justice and his disdain for basic constitutional rights.”

Bergdahl became a political talking point in 2014 after President Barack Obama’s administration traded five detainees at Guantanamo Bay in exchange for his release.

In February, Bergdahl’s defense team argued he was unable to have a fair trial after Donald Trump became president because of comments Trump made on the 2016 campaign trail.

During the campaign, Trump called Bergdahl a “dirty, rotten traitor” and said he “should be shot” for deserting his post. “In the good old days, he would have been executed,” Trump said.

Bergdahl’s attorneys argued that the comments, as well as critical words from Sen. John McCain, violated his right to due process. But Col. Nance ultimately ruled against dismissing the charges, saying that while Trump’s comments were “troubling,” they did not constitute a due process violation.

“Trump — when he was a candidate, of course — made really extraordinary and reprehensible comments targeted directly at our client,” Fidell said Friday. “It’s one of the most preposterous state of affairs that I can think of in American legal history.”

Investigator said jail time would be ‘inappropriate’

Since his return home to the United States, the 31-year-old from Idaho has been the subject of scrutiny while the US military investigated his decision to leave his post.

Bergdahl has said he abandoned his post because he wanted to travel to a larger base to report “a critical problem in my chain of command,” though he did not specify what the problem was.

He was charged with desertion and misbehavior before the enemy in March 2015.

Kenneth Dahl, the Army general who led the investigation into Bergdahl’s actions and interviewed the soldier for a day and a half, previously testified in a preliminary hearing that jail time would be “inappropriate.”

During his time in captivity, Bergdahl said he was tortured, beaten and spent months chained to a bed or locked in a cage while his health deteriorated. For five years, he said, he was completely isolated, had no concept of time and was told he would be killed and never see his family again.