The sole American prisoner of war held in Afghanistan was flown to a US military hospital in Germany yesterday, after he was dramatically freed in a swap deal for five Taliban militants who were released from the Guantanamo Bay prison in Cuba.

Army Sergeant Bowe Bergdahl had been held for nearly five years and his release, following years of on-and-off negotiations, suddenly became possible after harder-line factions of the Afghan Taliban shifted course and agreed to back it, according to US officials.

A US defence official said Bergdahl was able to walk and became emotional on his way to freedom, after being handed over to US special forces in eastern Afghanistan on Saturday.

“Once he was on the helicopter, he wrote on a paper plate, ‘SF?’” the official said, referring to the abbreviation for special forces.

“The operators replied loudly: ‘Yes, we’ve been looking for you for a long time.’ And at this point, Sergeant Bergdahl broke down.”

US Defence Secretary Chuck Hagel said he hoped the successful prisoner exchange deal might lead to breakthroughs in reconciliation with the militants.

“We had been working to find ways to open up some possibilities with the Taliban to try to get Sergeant Bergdahl back. This didn’t just start,” Hagel told reporters traveling with him on a routine visit to Afghanistan.

“This has been an ongoing effort that our government has been involved in at every level. We found some openings that made sense to us,” he added.

“The timing was right, the pieces came together.”

Hagel later met with more than a dozen special operations soldiers at the giant Bagram military base outside Kabul and thanked them for their part in operations to recover Bergdahl.

The timing was right, the pieces came together

Addressing a larger gathering of troops in a hangar at the base, Hagel said, “This is a happy day for our country, because we got one of our own back.”

Bergdahl, 28, was handed over about 6pm local time on Saturday, a senior official said.

The US forces, who had flown in by helicopter, were on the ground very briefly, said the officials, who would not specify the precise location.

“Fortunately, no shots were fired, there was no violence,” said Hagel. “It went as well, not only as we had expected and planned but I think as well as it could have.”

The commander of US and Nato forces in Afghanistan, General Joseph Dunford, spoke of the sense of excitement that swept the headquarters of the international military force there as news of the successful operation filtered through.

“You almost got choked up,” he said. “It was pretty extraordinary. It has been almost five years and he is home.”

President Barack Obama hailed the release in a brief appearance with Bergdahl’s parents, Bob and Jani, in the White House Rose Garden, saying that “while Bowe was gone, he was never forgotten”.

Bergdahl had already left Afghanistan when Hagel touched down at Bagram yesterday, and a US defense official later said the newly released POW had arrived at Landstuhl Regional Medical Center in Germany.

Another defense official said it was expected that after treatment in Germany he would be transferred to another military medical facility in San Antonio, Texas.

Bergdahl, who is from Idaho, was the only known missing US soldier in the Afghan war that was launched soon after the September 11, 2001 attacks on the US to force the Taliban – accused of sheltering al-Qaeda militants –from power.

In exchange for Bergdahl’s freedom, the US released five Taliban detainees from Guantanamo.

They were being flown to Qatar, the Gulf emirate that acted as an intermediary in the negotiations.

Sign up to our free newsletters

Get the best updates straight to your inbox:
Please select at least one mailing list.

You can unsubscribe at any time by clicking the link in the footer of our emails. We use Mailchimp as our marketing platform. By subscribing, you acknowledge that your information will be transferred to Mailchimp for processing.