Sergeant Bergdahl was captured by Taliban militants within hours of disappearing from his remote outpost, and was held captive for five years.

He endured torture, including beatings with rubber hoses and copper cables, that his military debriefer later characterized as the most profound abuse sustained by any American service member since the Vietnam War. He was released in May 2014, when the Obama administration freed five detainees from Guantánamo Bay, Cuba, in exchange for him.

His case soon turned into a politically charged referendum in Washington on the Obama administration’s foreign policy. After he was freed, President Barack Obama’s national security adviser, Susan E. Rice, said Sergeant Bergdahl, who was promoted while in captivity, had served with “honor and distinction,” and Mr. Obama appeared with his parents at the White House.

But Republicans attacked the trade that led to his release, and some critics asserted that he had deserted to the Taliban or that some troops had died searching for him. During the presidential race last year, Mr. Trump also described the sergeant a “dirty rotten traitor” and called for him to be executed.

At a preliminary hearing, the Army’s chief investigator, Maj. Gen. Kenneth Dahl, testified that he had found no evidence that any soldiers had been killed while specifically searching for Sergeant Bergdahl. Neither was there evidence that the sergeant intended to desert and join the Taliban, he said.

General Dahl — now a lieutenant general — also testified that he found Sergeant Bergdahl to be truthful, albeit naïve and delusional, and that jailing the sergeant would be “inappropriate.”

Sergeant Bergdahl’s defense team later argued that Mr. Trump’s comments made a fair trial impossible, since everyone who could play a role in deciding his fate — including prosecutors, the judge and the general who controls the case — now ultimately reports to Mr. Trump as commander-in-chief. But Colonel Nance concluded that while Mr. Trump’s comments were “disturbing,” there was no reason to dismiss the charges.