US Army Sergeant Bowe Bergdahl's guilty plea to charges of endangering comrades in Afghanistan has set up a sentencing hearing that could land him in prison for life.
Bergdahl, who was captured and held by the Taliban for five years after leaving his remote post in Afghanistan in 2009, pleaded guilty on Monday in North Carolina to desertion and misbehaviour before the enemy, a rare charge that carries a potential life sentence.
Because Bergdahl had no plea deal with prosecutors, his punishment will be decided by the judge, Army Colonel Jeffery R. Nance, at a hearing starting on October 23.
Bergdahl was thoroughly questioned by Col Nance at his plea hearing at Fort Bragg, and the soldier acknowledged that his actions, and subsequent military search missions, put fellow service members in harm's way.
"I left my fellow platoon mates," he told the judge.
"That's very inexcusable."
At sentencing, the judge is expected to weigh factors including Bergdahl's willingness to accept responsibility by pleading guilty, his time in captivity of the Taliban and its allies, and serious wounds to service members who searched for him.
"Pleading guilty before a judge without any protection from a deal is a risky move," said Eric Carpenter, a former Army lawyer who teaches law at Florida International University.
"The military judge can sentence Bergdahl to zero punishment, but he can also sentence Bergdahl to life in prison."
The guilty plea brings the highly politicised saga closer to an end eight years after Bergdahl vanished.
President Barack Obama brought him home in 2014 in a swap for five Taliban prisoners at Guantanamo Bay, saying the US does not leave its service members on the battlefield.
Republicans roundly criticised Mr Obama, and Donald Trump went further while campaigning for president, repeatedly calling Bergdahl a "dirty, rotten traitor" who deserved to be executed by firing squad or thrown out of a plane without a parachute.
Bergdahl, 31, has said he walked away from his remote post in 2009 with the intention of reaching other commanders and drawing attention to what he saw as problems with his unit.
"At the time, I had no intention of causing search-and-recovery operations," he said in court. "I believed they would notice me missing, but I didn't believe they would have reason to search for one private."
Bergdahl's responses to the judge on Monday were some of his most extensive public comments yet.
He said he tried to escape from his captors 12 to 15 times, with varying degrees of success.
Once, he was on his own for about a week, hoping US drones would spot him, before he was recaptured.
He said he also tried to escape on his first day in captivity.
"As I started running there came shouts, and I was tackled by people. That didn't go so well," said Bergdahl, who spoke in even tones and wore a blue dress uniform.
Meanwhile, Bergdahl's fellow service members engaged in firefights that they could have avoided had Bergdahl not gone absent without leave, the judge said.
Those firefights left a Navy Seal with a career-ending leg wound and an Army National Guard sergeant with a head wound that put him in a wheelchair.