WASHINGTON - U.S. Army Sergeant Bowe Bergdahl, who is charged with desertion for walking away from his combat post in Afghanistan in 2009, has asked President Barack Obama for a pardon, the White House said on Saturday.

Obama will relinquish office on Jan. 20 to Republican President-elect Donald Trump, who made caustic comments about the sergeant during the presidential campaign that drew complaints from Bergdahl’s defense team.

Trump savaged Bergdahl as “a no-good traitor who should have been executed” and criticized the prisoner swap in 2014 that won his release.

Bergdahl, 30, is facing a court-martial with a potential life sentence on charges of desertion and endangerment of U.S. troops after he walked away from his post in Afghanistan. He was captured by the Taliban and became a prisoner for five years.

The White House has received Bergdahl’s pardon application, but could not comment on pending cases per standard practice, an official said on Saturday on condition of anonymity.

U.S. military prosecutors have said the 45-day search for Bergdahl after he left his post put soldiers’ lives at risk and diverted attention from the fight against the Taliban.

Bergdahl was freed in a prisoner swap involving the release of five Taliban leaders held by the United States. The deal drew heavy criticism from Republicans.

In January, Bergdahl lawyer Eugene Fidell said Trump had made “appalling” comments about the sergeant and might be called as a witness in the court-martial.

In August, defense lawyers asked to have the charges against the former prisoner of war dismissed, arguing comments made by Senate Armed Services Committee Chairman John McCain violated his due process rights. The filing quoted McCain as saying the committee would hold a hearing if Bergdahl received no punishment and that U.S. soldiers’ lives were put in danger by having to look for him.

Now that Trump is president-elect, a fair military trial will be impossible, Fidell told The New York Times.

“I have grave concerns as to whether Sergeant Bergdahl can receive a fair trial given the beating he has taken over many months from Mr. Trump, who will be commander in chief, as well as Senator McCain’s call for a hearing in case Sergeant Bergdahl is not punished,” Fidell said. “It is really most unfair.”

(Reporting by Doina Chiacu; Editing by Alistair Bell)