Disgraced Army Sgt. Bowe Bergdahl, who abandoned his post in Afghanistan and was held prisoner by the Taliban for five years, is expected to plead guilty to desertion and misbehavior before the enemy.

Bergdahl’s decision to admit his guilt rather than face trial marks another twist in a bizarre 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.

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

It’s unclear whether the Idaho native, 31, will be locked up or receive a lesser sentence that reflects the time the Taliban held him under brutal conditions.

He has said he was caged, kept in the dark, 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 chose 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.

Sentencing will start on Oct. 23, individuals with knowledge of the case told the Associated Press.

During sentencing, US troops who were seriously wounded searching for Bergdahl in Afghanistan are expected to testify, the sources 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.

Bergdahl’s lawyer, Eugene Fidell, declined to comment on Friday. Maj. Justin Oshana, who is prosecuting the case, referred questions to the Army, which declined to discuss whether Bergdahl had agreed to plead guilty.

“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, and the US kept tabs on him with drones, spies and satellites as behind-the-scenes negotiations played out in fits and starts.

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

As critics questioned whether the trade was worth it, President Obama stood with Bergdahl’s parents in the White House Rose Garden and defended the swap.

The US does not “leave our men or women in uniform behind,” Obama said, regardless of how Bergdahl came to be captured.

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.

With AP