U.S. Army Sergeant Bowe Bergdahl, who walked away from his post in Afghanistan and became a prisoner of the Taliban for five years, will face court-martial on charges of desertion and endangering U.S. troops, the Army said on Monday.

Bergdahl, 29, was charged earlier this year and faces up to life in prison if convicted of the more serious offense of endangering troops who searched for him in lawless areas of Afghanistan after his disappearance in 2009.

The date of the arraignment hearing at Fort Bragg, North Carolina, will be announced later, the U.S. Army Forces Command said in a statement.

The head of the Army team that investigated Bergdahl has said he does not believe he should face jail time. Prosecutors contend he should be punished for leaving his post and causing a massive search operation.

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 who were being held at Guantanamo 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 disappearance and capture, testified at a military probable cause hearing in September in San Antonio, Texas that Bergdahl was not a Taliban sympathizer and no soldiers directly involved in the search for him were killed.

Dahl characterized Bergdahl, who has been stationed at a joint base in San Antonio since his return to the United States, as an unrealistically idealistic soldier who left his post to report concerns about his unit's leadership to a general at another base.

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

U.S. military prosecutors said at the hearing in September, that Bergdahl snuck away from his post under the cover of night on a plan that was weeks in the making.

They said there was sufficient evidence to hold him for trial on charges of desertion and misbehavior before the enemy.

Testifying for the defense at that hearing, Terrence Russell, an expert with the military's Joint Personnel Recovery Agency, said in his five years of captivity, Bergdahl 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.

Bergdahl said in a podcast launched on Thursday that he left his post in Afghanistan to draw attention to "leadership failure" in his unit.

(Reporting by Jon Herskovitz; Additional reporting by Jim Forsyth in San Antonio andDavid Alexander in Washington; Editing by Leslie Adler and Cynthia Osterman)