U.S. soldiers in Afghanistan
U.S. soldiers in AfghanistanReuters

US Army Sergeant Bowe Bergdahl, 28, who has been held by the Taliban in Afghanistan for nearly five years has been freed in deal that includes the release of five Afghan detainees, US officials said.

The  Afghan detainees have been released from the US prison at Guantanamo Bay, Cuba.

They were handed over to Qatar, which mediated the transfer.

Sgt Bergdahl was the only US soldier being held by the Taliban in Afghanistan.

Officials said he was in good condition and able to walk. He is expected to be transferred to Bagram Air Field, the main US base in Afghanistan, and then on to the United States.

In a statement, President Barack Obama said Sgt Bergdahl's recovery "is a reminder of America's unwavering commitment to leave no man or woman in uniform behind on the battlefield.”

Officials said 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.

A senior official told the BBC that, once aboard the US helicopter, Sgt Bergdahl wrote "SF?" - asking if they were special operations forces – on a paper plate and showed it to the pilots, who replied: "Yes, we've been looking for you for a long time."

The senior official said: "At that point, Sgt Bergdahl broke down.”