AUSTIN, Texas (Reuters) - U.S. Army Sergeant Bowe Bergdahl, who walked away from his post in Afghanistan and became a Taliban prisoner for five years, will face court-martial with a potential life sentence, the Army said on Monday.

U.S. Army Sergeant Bowe Berghdal is pictured in this undated handout photo provided by the U.S. Army and received by Reuters on May 31, 2014. REUTERS/U.S. Army/Handout via Reuters

Bergdahl, 29, was charged earlier this year with desertion and endangering U.S. troops and could face the life sentence if convicted of the latter, more serious offense.

In ordering the court martial on Monday, Army General Robert Abrams did not follow the recommendation of a preliminary hearing which, according to Bergdahl’s lawyer, called for Bergdahl to face a proceeding that could impose a potential maximum penalty of a year in confinement.

Bergdahl’s lawyer, Eugene Fidell, said the defense team “had hoped the case would not go in this direction.” He also urged Republican presidential candidate Donald Trump, who has called Bergdahl a “dirty, rotten traitor,” to “cease his prejudicial months-long campaign of defamation against our client.”

Bergdahl disappeared on foot on June 30, 2009, from Combat Outpost Mest-Malak in Paktika Province, Afghanistan, and was subsequently captured by the Taliban.

He left his post to draw attention to “leadership failure” in his unit, Bergdahl said last week on the popular podcast Serial, which is focusing a season on his case.

The Idaho native suffered torture, abuse and neglect at the hands of Taliban forces, including months of beatings and being confined for 3-1/2 years to a metal cage barely big enough to stand in, a military expert testified previously.

The head of the Army team that investigated Bergdahl has said he does not believe he should face jail time.

The official search for Bergdahl lasted 45 days, but the United States spent years trying to determine his whereabouts and bring him home.

He was freed in a prisoner swap in May 2014 that sent five Taliban leaders held by the United States at Guantanamo Bay to Qatar, where they had to remain for a year. The deal drew heavy criticism from Republicans.

Major General Kenneth Dahl, who led the military’s investigation of Bergdahl’s case, testified at a military probable cause hearing in September that Bergdahl was not a Taliban sympathizer and no soldiers directly involved in the search for him were killed.

Jeff Addicott, an Army officer in the Judge Advocate General’s Corps for 20 years and a law professor at St. Mary’s University, said Bergdahl, who has been stationed at a base in San Antonio, Texas, may now be confined to his base.

“He is going to be watched very closely now because he has left his place of duty before in a combat zone and he may try to do it again,” he said.

Bergdahl may also seek to have his case heard by a judge instead of a panel of military personnel, which would likely include members who were deployed in Afghanistan, he said.

The date of Bergdahl’s arraignment hearing at Fort Bragg, North Carolina, will be announced later, the Army said. U.S. military prosecutors did not comment on Monday’s decision.