US army sergeant Bowe Bergdahl, the former prisoner of war who is accused of endangering comrades by walking off his post in Afghanistan, is asking President Barack Obama to pardon him before leaving office.

White House and Justice Department officials said on Saturday that Bergdahl had submitted copies of the clemency request seeking leniency.

If granted by Obama, it would allow Bergdahl to avert a military trial scheduled for April where he will face charges of desertion and misbehavior before the enemy. The misbehavior charge carries a maximum penalty of life in prison.

If the pardon isn’t granted, Bergdahl’s defense team said it would expand its legal strategy to the new administration by filing a motion arguing President-elect Donald Trump violated Bergdahl’s due process rights with scathing public comments about the case.

The pardon request to Obama, first reported by the New York Times, was confirmed by White House and Justice Department officials who weren’t authorized to discuss the matter by name.

Bergdahl, of Hailey, Idaho, walked off his post in Afghanistan in 2009 and was held captive by the Taliban and its allies for five years.

The Obama administration’s decision in May 2014 to exchange him for five Taliban prisoners held at Guantánamo Bay, Cuba, prompted criticism that included some Republicans accusing Obama of jeopardizing nation’s safety.

Some lawmakers were outraged that the administration didn’t give Congress a 30-day notice about transferring the detainees, as required by law.

Throughout his presidential campaign, Trump was Bergdahl’s most vocal critic, saying repeatedly the soldier is a traitor who would have been executed in the “old days”. In a July speech in Indiana, Trump lamented that Bergdahl could wind up with a light punishment.

“Remember the old days? A deserter, what happened?” he said before pantomiming pulling a trigger and adding: “Bang.”

Bergdahl’s lead defense lawyer, Eugene Fidell, declined to comment on the pardon request. But Fidell said he plans to file a motion seeking dismissal of the charges against Bergdahl shortly after the January inauguration, arguing Trump violated Bergdahl’s constitutional due-process rights.

The defense has been noting Trump’s comments about Bergdahl in what they have called the “Trump Defamation Log”. A version included in the court record lists 40 such instances as of August.

“All of these things put together and repeated rally upon rally for basically a year have a cumulative effect that I think is totally at odds with the right to a fair trial,” Fidell said in a phone interview.

A spokeswoman for Trump did not respond to emails seeking comment.

There is precedent for a military judge to decide a president’s comments have tainted a military prosecution.

In 2013, a navy judge cited comments by Obama when he issued a pretrial order that two defendants in sexual assault cases could not be punitively discharged if they were found guilty. The judge wrote that Obama’s public comments about cracking down on sexual assault, specifically referencing dishonorable discharges, appeared to be demand particular results from military courts.

“People in the military do what their commanders tell them to do,” said Eric Carpenter, a law professor at Florida International University who served as an army lawyer.

Carpenter added that there is a risk that military jurors could punish Bergdahl because they think it’s what their commander-in-chief wants, rather than deciding strictly on the evidence.

Carpenter said he would be surprised if the army judge dismissed the charges entirely, but he could give the defense leeway to question potential jurors and reject them based on their answers about Trump.

Bergdahl, who faces trial at Fort Bragg, has said he walked off his post in Afghanistan because he wanted to cause an alarm and draw attention to what he saw as problems with his unit.