Sergeant Bowe Bergdahl
Sergeant Bowe Bergdahl was said to be weakened and scared after five years in a Taliban prison.

A US soldier held captive by the Taliban in Afghanistan for almost five years has been released.

Sergeant Bowe Bergdahl, from Idaho, was freed in a prisoner swap after America turned over five Taliban detainees held in the US prison in Guantanamo Bay.

Sergeant Bergdahl was taken prisoner in the Paktia Province of Afghanistan on June 30, 2009.

Officials confirmed that the Taliban had handed him over on Saturday evening, local time, in eastern Afghanistan.

Several dozen US Special Forces were involved in the exchange, they said, which took place near the Pakistani border.

Sources say he is "weakened, scared and vulnerable", and is undergoing a medical examination in Germany.

The parents of the freed soldier, Bob and Jani Bergdahl who had campaigned for his release, said in a statement that they were "joyful and relieved."

"We cannot wait to wrap our arms around our only son," they said.

Commenting on the return of the missing soldier, US President Barack Obama said America was committed to leaving no soldier behind.

"On behalf of the American people, I was honoured to call his parents to express our joy that they can expect his safe return, mindful of their courage and sacrifice throughout this ordeal.

"Sergeant Bergdahl's recovery is a reminder of America's unwavering commitment to leave no man or woman in uniform behind on the battlefield. And as we find relief in Bowe's recovery, our thoughts and prayers are with those other Americans whose release we continue to pursue."

Mr Obama expressed his gratitude to the Amir of Qatar for helping secure the soldier's release, and also the support of the Afghanistan government following months of indirect contact with the militants.