Transcript for Bowe Bergdahl responds to those who called him a traitor
He's garbage. He's a dirty, rotten traitor. A no-good rotten traitor. Reporter: Other than Hillary Clinton, no American has been more attacked or savaged by Donald Trump than this army sergeant, Bowe Bergdahl. In the old days, when we were strong, you know what happens to Bergdahl, bing dong, he's gone. Reporter: After walking off his post in Afghanistan, Bergdahl was captured by the Taliban for five years. Before being turned over in this dramatic moment. ??? ??? Reporter: Today Bergdahl at a court-martial hearing pleaded guilty to desertion. He told the military judge, I understand leaving was against the law. I understood. I endangered the safety of my platoon. The army says at least two soldiers were seriously wounded went they searched for Bergdahl. Tonight he says the words of candidate Donald Trump, who is now his commander in chief, would have made a fair trial impossible. Might as well go back to kangaroo courts and lynch mobs. They got what they wanted. The people who want to hang me, you're never gonna convince those people. And it goes quickly, right? It's called, you're dead. The people who were to the point of saying, just shoot him. You could never convince those people to change their minds. And it hurts? It does hurt. Reporter: Bergdahl talking in a small shed where he spends a lot of time, described how he survived his five years in captivity to a British filmmaker who himself was held captive by the same Taliban group. I mean, you're in survival mode. There really are no rules. Just to, you know, when it comes to drinking urine, when it comes to eating food that has been thrown in the dirt that you know is mixed with feces. There's no rules to surviving. This is a Fox News alert -- Reporter: And Bergdahl scoffs at reports that he was well treated and had actually joined up with the Taliban. Sergeant Bowe Bergdahl was said to have declared himself a warrior for Islam. It's insulting. It's very insulting the idea that they think I did that. Reporter: In fact, says Bergdahl, he twice tried to escape from the Taliban compound where he was held somewhere in Pakistan. It was getting so bad that I was literally looking at myself, looking at my joints, looking at my ribs, I was going, um, I'm just going to die here from sickness, or, you know, I can die escaping. You know, it didn't really matter. Reporter: He says in one escape attempt, he was on the run for several days before being caught. And then put in a cage like an animal. It's a cage that was welded together, about a seven-foot-long, by about six-foot-wide and maybe about six feet by one inch tall. And how long were you in the cage for? Second, third, fourth, and into the fifth year. Reporter: The military official who debriefed former U.S. Captains said Bergdahl was horribly treated and tortured. Ngets when they recaptured him and brought him back, they spread eagled and secured him to a metal bed frame. While he was shackled in that position, they took a plastic pipe, I imagine it was like a plumbing pipe, and they started beating his feet and his legs repeatedly with this plastic pipe. Later they moved to using a copper cable. The idea was to just beat him and injure his legs and his feet so that he could not walk away again. Reporter: As all of this was happening, Bergdahl's plight was being monitored at the Pentagon by the head of the defense intelligence agency. I am lieutenant general retired Mike Flynn. Reporter: Who became president trump's top national security adviser and is now at the center of the Russian investigation, was also interviewed about Bergdahl. For the first 24 to 72 hours, we were in crisis operations, and we were -- I was personally diverting every single capability, human intelligence wise, to signals intelligence, to unmanned aerial vehicles, to space-based systems. I mean, we really turned on, to find this soldier. So you believe, sir, that he did walk off the base, with the intention of meeting the Taliban? Absolutely. Absolutely. Reporter: Bergdahl disputes that he ever planned to join the Taliban. Claiming in the serial podcast that he walked off post in an attempt to report that his platoon commander was a bad leader. He was out of control, from what I could see. He was unfit for what he was doing. Reporter: A military judge found Bergdahl's observations about his commander to be unreasonable and incorrect. Whatever Bergdahl's reasons for deserting, president Obama said, they were not a factor in the U.S. Efforts to gain his freedom. The United States of America does not ever leave our men and women in uniform behind. Reporter: A team of U.S. Special forces carried out the operation in a remote area of Pakistan. Bergdahl says he was too overcome with emotion to even cry. The five years I was dealing with, it was like -- it's a pain that goes beyond anything that -- it's so overwhelming, crying doesn't do anything. It gets stuck. Reporter: But to gain his freedom, the Obama administration agreed to release five Taliban prisoners from Guantanamo, a decision harshly criticized during the election campaign. We get a no-good traitor, and they get the five people that they wanted for years, and those people are now back on the battlefield, trying to kill us. Reporter: Now that Bergdahl has pleaded guilty to desertion, a military judge will decide next week what his punishment should be, including the possibility of prison. Bergdahl has his defenders. You couldn't ask for a better soldier in captivity than what Bowe Bergdahl did. He continued to fight the enemy. He continued to resist. He escaped within weeks of his initial capture. He's escaping and trying to get away from them. Reporter: And some who believe he did act dishonorably still think he's suffered enough, including general Flynn. I don't think that he should serve another day in any sort of confinement or jail or anything like that. Because, frankly, even though he put himself into this situation, we, the United States government, put him in Afghanistan. Reporter: For "Nightline," Brian Ross, ABC news, New York.
This transcript has been automatically generated and may not be 100% accurate.