Fort Bragg, North Carolina (CNN) 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.

The judge ordered that Bergdahl's rank be reduced from sergeant to private. Additionally, Bergdahl 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 proceedings.

"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 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.

Gen. Robert Abrams, the commanding general of Forces Command and the convening authority in Bergdahl's case, will review the sentence, according to Paul Boyce, an Army spokesman. Abrams could potentially reduce Bergdahl's sentence.

Defense: Bergdahl 'should not have been in the Army'

"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.

JUST WATCHED Report: Bergdahl diagnosed with personality disorder Replay More Videos ... MUST WATCH Report: Bergdahl diagnosed with personality disorder 01:28

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."

The decision on Sergeant Bergdahl is a complete and total disgrace to our Country and to our Military. — Donald J. Trump (@realDonaldTrump) November 3, 2017

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.

President Obama created a VERY BAD precedent by handing over five Taliban prisoners in exchange for Sgt. Bowe Bergdahl. Another U.S. loss! — Donald J. Trump (@realDonaldTrump) June 1, 2014

Fidell had denounced Trump's critical campaign comments, saying "every American should be offended by his assault on the fair administration of justice and his disdain for basic constitutional rights."

"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.