Sgt. Bowe Bergdahl pleaded guilty to desertion and misbehavior before the enemy via his attorney Monday.

Bergdahl, 31, was charged after he disappeared from his base in Afghanistan in June 2009 and was held in captivity by the Taliban until May 2014.

A judge said Bergdhal's maximum possible punishment would be life in prison, but he has not been sentenced yet.

After his capture, Bergdahl said he made "somewhere between a dozen and 15 escape attempts."

The Taliban released Bergdahl in a prisoner swap for five detainees at Guantanamo Bay.

During questioning from a judge Monday, Bergdahl said, "I left my observation post on my own." He also said, "I understand leaving was against the law."

Bergdahl has been called both a traitor and a hero.

Six soldiers' deaths have been tied, either directly or indirectly, to the search for Bergdahl during his disappearance in Afghanistan, former unit members alleged.

In 2015, an Army Sanity Board evaluation said, Bergdahl had schizotypal personality disorder. That information was included in the hundreds of pages of documents that Bergdahl's defense team releases on a website called The Bergdahl Docket.

Developing story - more to come

The-CNN-Wire™ & © 2017 Cable News Network, Inc., a Time Warner Company. All rights reserved.