Army Sgt. Bowe Bergdahl, who was held captive by the Taliban for half a decade after abandoning his Afghanistan post, is expected to plead guilty to desertion and misbehavior before the enemy, two individuals with knowledge of the case said.

Then-president Barack Obama celebrated Bergdahl's rescue in a May 2014 White House Rose Garden ceremony, accompanied by the sergeant's parents.

Two days later, then-National Security Advisor Susan Rice declared in a TV interview that Bergdahl 'served the United States with honor and distinction' and 'was an American prisoner of war captured on the battlefield.'

President Donald Trump has called Bergdahl a 'no-good traitor' who 'should have been executed.'

Army Sgt. Bowe Bergdahl is pictured arriving for a pretrial hearing at Fort Bragg, N.C. in 2016 Bergdahl, who was held captive by the Taliban for half a decade after walking away from his post in Afghanistan

Bergdahl, pictured after his arraignment in December 2015, is expected to plead guilty this month rather than face trial for desertion and misbehavior before the enemy

As Bergdahl's parents looked on, President Barack Obama made a glowing statement at the White House about Bergdahl's release on May 31, 2014

Bergdahl's decision to plead guilty rather than face trial marks another twist in an eight-year drama that caused the nation to wrestle with difficult questions of loyalty, negotiating with hostage takers and America's commitment not to leave its troops behind.

The decision by the 31-year-old Idaho native leaves open whether he will return to captivity for years – this time in a U.S. prison – or receive a lesser sentence that reflects the time the Taliban held him under brutal conditions. He says he had been caged, kept in darkness, beaten and chained to a bed.

Bergdahl could face up to five years on the desertion charge and a life sentence for misbehavior.

Freed three years ago, Bergdahl had been scheduled for trial in late October. He had opted to let a judge rather than a military jury decide his fate, but a guilty plea later this month will spare the need for a trial.

The quintet of jihadi terrorists whom Obama released in exchange for Bergdahl's return became known as the 'Taliban five'

Sentencing will start on Oct. 23, according to the individuals with knowledge of the case. They weren't authorized to discuss the case and demanded anonymity. During sentencing, U.S. troops who were seriously wounded searching for Bergdahl in Afghanistan are expected to testify, the individuals said.

It was unclear whether prosecutors and Bergdahl's defense team had reached any agreement ahead of sentencing about how severe a penalty prosecutors will recommend.

An attorney for Bergdahl, Eugene Fidell, declined to comment on Friday. Maj. Justin Oshana, who is prosecuting the case, referred questions to the U.S. Army, which declined to discuss whether Bergdahl had agreed to plead guilty.

Then-National Security Advisor Susan Rice lauded Bergdahl on ABC in 2014, saying he had 'served with honor and distinction'

The Idaho native was returned to the U.S. in exchange for five high-value terrorist prisoners held at the Guantanamo Bay military prison

'We continue to maintain careful respect for the military-judicial process, the rights of the accused and ensuring the case's fairness and impartiality during this ongoing legal case,' said Paul Boyce, an Army spokesman.

Bergdahl was a 23-year-old private first class in June 2009 when, after five months in Afghanistan, he disappeared from his remote infantry post near the Pakistan border, triggering a massive search operation.

Videos soon emerged showing Bergdahl in captivity by the Taliban, who ruled Afghanistan in the years before the Sept. 11, 2001, attacks and harbored al-Qaida leaders including Osama bin Laden as they plotted against America. For years, the U.S. kept tabs on Bergdahl with drones, spies and satellites as behind-the-scenes negotiations played out in fits and starts.

In May 2014, he was handed over to U.S. special forces in a swap for five Taliban detainees at the Guantanamo Bay prison, fueling an emotional U.S. debate about whether Bergdahl was a hero or a deserter.

As critics questioned whether the trade was worth it, President Barack Obama stood with Bergdahl's parents in the White House Rose Garden and defended the swap. The United States does not 'leave our men or women in uniform behind,' Obama declared, regardless of how Bergdahl came to be captured. The Taliban detainees were sent to Qatar.

BOWE BERGDAHL: A TIMELINE Army Sgt. Bowe Bergdahl, who spent five years in captivity in Afghanistan after abandoning his post, is expected to plead guilty to desertion and misbehavior before the enemy. A look at key events from his capture until now: June 2009 - Bergdahl, who is serving with an Alaska-based infantry regiment, vanishes from a base in Afghanistan's Paktika province near the border of Pakistan. July 2009 - The Taliban post video online showing Bergdahl saying he is 'scared I won't be able to go home.' Bergdahl says he was lagging behind a patrol when he was captured. December 2009 - The Taliban release a video showing Bergdahl apparently healthy and making a lengthy statement criticizing the U.S. military operation. June 2013 - The Taliban propose a deal in which they would free Bergdahl in exchange for five of their most senior operatives at Guantanamo Bay. May 2014 - Obama administration officials announce Bergdahl has been handed over to U.S. special forces by the Taliban in exchange for the release of five Guantanamo detainees. Debate quickly rises over whether Bergdahl is a hero or a deserter. June 2014 - The Army says it is investigating the facts and circumstances around Bergdahl's disappearance. December 2014 - The Army says it has finished its investigation. March 2015 - Bergdahl is charged with desertion and misbehavior before the enemy. October 2017 - People familiar with the case tell the AP that Bergdahl is expected to plead guilty to desertion and misbehavior before the enemy. Advertisement

'Whatever those circumstances may turn out to be, we still get an American soldier back if he's held in captivity,' Obama said. 'Period. Full stop.'

Trump, as a presidential candidate, was unforgiving of Bergdahl, who has been assigned to desk duty at a Texas Army base pending the outcome of his case. At campaign events, Trump declared that Bergdahl 'would have been shot' in another era, even pantomiming the pulling of the trigger.

'We're tired of Sgt. Bergdahl, who's a traitor, a no-good traitor, who should have been executed,' Trump said at a Las Vegas rally in 2015.

Bergdahl's guilty plea will follow several pretrial rulings against him that had complicated his defense. Army Col. Jeffery R. Nance, the judge, decided in June that testimony from troops wounded as they searched for him would be allowed during sentencing, a decision that strengthened prosecutors' leverage to pursue stiffer punishment.

Some of Bergdahl's fellow soldiers want him held responsible for any harm suffered by those who went looking for him. The judge ruled a Navy SEAL and an Army National Guard sergeant wouldn't have found themselves in separate firefights if they hadn't been searching.

The defense separately argued Trump's scathing criticism unfairly swayed the case. The judge ruled otherwise. Nance wrote in February that Trump's comments were 'disturbing and disappointing' but didn't constitute unlawful command influence by the soon-to-be commander in chief.

Bergdahl's lawyers also contended that misbehavior before the enemy, the more serious charge, was legally inappropriate and too severe. They were rebuffed again. The judge said a soldier who leaves his post alone and without authorization should know he could face punishment. The misbehavior charge has rarely been used in recent decades, though there were hundreds of cases during World War II.

Defense attorneys don't dispute that Bergdahl walked off his base without authorization. Bergdahl himself told a general during a preliminary investigation that he left intending to cause alarm and draw attention to what he saw as problems with his unit. An Army Sanity Board Evaluation concluded he suffered from schizotypal personality disorder.

The defense team has argued that Bergdahl can't be held responsible for a long chain of events that included decisions by others about how to retrieve him that were far beyond his control.