Army Sgt. Bowe Bergdahl, now 30, who faces charged of desertion after walking off his combat outpost in Afghanistan before being captured has asked President Obama for a pardon before he leaves office.

Bergdahl was held for five years by the Taliban, has asked President Obama for a pardon before he leaves office in the hope of avoiding a trial which could land him in jail for the rest of his life.

According to Fox News, Bergdahl wrote to Mr Obama to thank the president for rescuing him in May 2014.

The rescue was controversial at the time because it resulted in the release of five Taliban prisoners from Guantanamo Bay. The letter also reportedly asked for a presidential pardon.

A Justice Department official has confirmed to Fox that it received a pardon petition from Bergdahl.

Scroll down for video

The charges of desertion and endangering troops against Bergdahl stem from his decision to leave his outpost in Afghanistan in 2009. He has now asked to be pardoned by Obama

His release from the Taliban was secured by President Obama who exchanged five Guantanamo Bay detainees for his safe return. Above, pictured while being held by the Taliban

President Obama has said that the U.S. military does not leave its men and women behind

President-elect Donald Trump called Bergdahl a 'dirty, rotten traitor'

Bergdahl was quickly captured after walking off his combat post in Afghanistan in 2009, and held as a prisoner by the Taliban and its allies until President Barack Obama exchanged five Guantanamo Bay detainees for his safe return, saying the US 'does not ever leave our men and women in uniform behind.'

Obama's decision was harshly criticized. Some members of Congress said it jeopardized national security.

During the U.S. military's intensive man-hunt for Bergdahl over a five-year period it was reported that up to six American soldiers died and others were wounded in the search, but these claims have been disputed.

Shortly after he was returned to US custody, President Obama's national security advisor Susan Rice said Bergdahl served his country with 'honor and distinction.'

Trump has targeted Bergdahl for scorn dozens of times on the campaign trail, saying among other things that he should have been thrown from a plane.

Bergdahl's trial is scheduled for April of next year, however his defense says President-elect Trump has already damaged his chances for a fair trial by calling him a 'dirty, rotten traitor,' who 'should have been executed.'

The Army's primary investigating officer last year recommended against Bergdahl facing jail time, saying there is no evidence that any service members were killed or wounded searching for him in Afghanistan.

Bergdahl, now 30, faces charges of desertion and misbehavior before the enemy. The latter charge is relatively rare and carries the potential of life in prison

The Taliban captured Bergdahl (pictured left looking thin) after he left his post in Afghanistan in 2009. He was freed years later, but will face trial in April 2017

Meanwhile, law enforcement officials have been notified that threats against Bergdahl continue.

'Given the many incendiary comments that have been broadcast and otherwise disseminated about Sgt. Bergdahl, his immediate commander at Fort Sam Houston has taken measures to ensure his physical safety when leaving the installation,' his attorneys wrote in February.

A spokesman at the Texas post declined to describe these measures, citing security considerations. But as 'a group of soldiers, battle buddies, we all look out for each other,' Sgt. Maj. Matt Howard said.

Bergdahl can come and go the same as any other soldier from Fort Sam Houston, where he works a desk job in a headquarters unit, handling 'a lot of administrative work that needs to be done. Paperwork, moving stuff from place to place, things like that,' Howard said.