The sole American prisoner of war held in Afghanistan was being flown to a U.S. military hospital in Germany on Sunday, after he was dramatically freed in a swap deal for five Taliban militants who were released from the Guantanamo Bay prison in Cuba, Reuters reported. 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 U.S. officials. A U.S. defense official said Bergdahl was able to walk and became emotional on his way to freedom, after being handed over to U.S. special forces in eastern Afghanistan on Saturday. U.S. Defense 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 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."