* U.S. army sergeant had been held by Taliban for nearly five years
* Five Taliban detainees released from Guantanamo in swap
* Freed soldier being flown to U.S. military hospital in Germany
* Qatar acted as intermediary in negotiations
* Hopes that prisoner swap could lead to broader Afghan peace talks (Adds details on talks)
By Warren Strobel
WASHINGTON, May 31 (Reuters) - The last U.S. prisoner of war held in Afghanistan was handed over to U.S. Special Operations forces on Saturday, in a dramatic swap for five Taliban detainees who were released from Guantanamo Bay prison and flown to Qatar.
Army Sergeant Bowe Bergdahl had been held for nearly five years by Afghan militants and his release, following years of on-and-off negotiations, suddenly became possible after harder-line factions of the Afghan Taliban apparently shifted course and agreed to back it, according to U.S. officials.
Bergdahl, 28, was handed over about 6 p.m. local time on Saturday, a senior official said. The U.S. forces, who had flown in by helicopter, were on the ground very briefly, said the officials, who would not specify the precise location of the handover.
A U.S. defense official said Bergdahl was able to walk and became emotional on his way to freedom.
"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."
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 was on his way to an American military hospital in Germany, a U.S. defense official said. Another defense official said it was expected that after treatment in Germany he would be transferred to a military medical facility in San Antonio, Texas.
U.S. special forces took custody of Bergdahl in a non-violent exchange with 18 Taliban members in eastern Afghanistan, senior U.S. officials said, adding that he was believed to be in good condition. Before leaving for Germany, he received medical care at Bagram Air Base, the main U.S. base in Afghanistan.
Within hours of his release, a second U.S. defense official said the five Taliban detainees, now formally in Qatari custody, had departed the Guantanamo prison. They were aboard a U.S. military C-17 aircraft and en route to the Gulf emirate.
The prisoner swap comes as America is winding down its long war in Afghanistan, and raises the question of whether this could lead to broader peace talks between the Taliban and the Afghan government for a negotiated end to the conflict.
"We do hope that having succeeded in this narrow but important step, it will create the possibility of expanding the dialogue to other issues. But we don't have any promises to that effect," said one senior U.S. official deeply involved in the diplomacy.
TOUGH RECOVERY PROCESS
Bergdahl, who is from Idaho, was the only known missing U.S. soldier in the Afghan war that was launched soon after the Sept. 11, 2001 attacks on the United States to force the Taliban - accused of sheltering al Qaeda militants - from power.
He was captured under unknown circumstances in eastern Afghanistan by militants on June 30, 2009, about two months after arriving in the country.
His recovery after long years in captivity could be difficult. At the White House, Bergdahl's father began his words speaking a Muslim prayer and said his son was having difficulty speaking English. He asked for patience from the media as the family helped him re-adjust.
A U.S. defense official said Bergdahl would continue treatment at Landstuhl Regional Medical Center in Germany, including the start of his "reintegration process".
"That includes time for him to tell his story, decompress, and to reconnect with his family through telephone calls and video conferences," the official said.
Bergdahl's release could be a national security boost for Obama, whose foreign policy has been widely criticized in recent months.
But some members of Congress have worried in the past over the potential release of the five Taliban detainees, particularly Mohammed Fazl, a "high-risk" detainee held at Guantanamo since early 2002. Fazl is alleged to be responsible for the killing of thousands of Afghanistan's minority Shi'ite Muslims between 1998 and 2001.
A U.S. defense official, speaking on condition of anonymity, identified the five men as Fazl, Mullah Norullah Noori, Mohammed Nabi, Khairullah Khairkhwa and Abdul Haq Wasiq. Pentagon documents released by the WikiLeaks organization said all five were sent to Guantanamo in 2002, the year the detention facility opened. They were classified as "high-risk" detainees "likely to pose a threat" to the United States, its interests and allies.
U.S. officials referred to the release of the Taliban detainees as a transfer and noted they would be subject to certain restrictions in Qatar. One of the officials said that would include a minimum one-year ban on them traveling outside of Qatar as well as monitoring of their activities.
Bergdahl's freedom followed a renewed round of indirect U.S.-Taliban talks in recent months, with Qatar acting as intermediary, the officials said.
The U.S. had been trying diplomacy to free Bergdahl since late 2010, but talks had been complicated, U.S. officials said, by an internal split between Taliban factions willing to talk to Americans and those staunchly opposed.
That changed in recent weeks - the exact time-frame is unclear - when Taliban hardliners reversed position, officials said.
The swap also comes days after Obama said he would keep 9,800 U.S. troops in Afghanistan, mostly to train Afghan forces, after NATO combat operations end at the end of 2014. The last soldiers, aside from a small presence at U.S. diplomatic posts, will leave at the end of 2016.
A U.S. official said he did not think there was a link with the announcement on Tuesday of the troop withdrawal timetable.
"This discussion predates the decision on troops," he said. "This is just a matter of things coming together with the help of the Qataris and the Taliban realizing that we were serious."
FAMILY, HOMETOWN CELEBRATE
The Bergdahl family was in Washington, D.C., when informed by Obama of the release. The parents said in a statement they were "joyful and relieved," adding: "We cannot wait to wrap our arms around our only son."
Bergdahl's hometown of Hailey, Idaho, also began celebrating.
"Once we heard about it. We were pretty excited," said 17-year-old Real Weatherly, who was making signs on Saturday and blowing up balloons to hang outside the shop where she works.
The Afghan Taliban confirmed on Saturday it had freed Bergdahl. "This is true. After several rounds of talks for prisoners' swap, we freed U.S. soldier and our dear guest in exchange of five commanders held in Guantanamo Bay since 2002," a senior Taliban commander said.
The Taliban commander said Bergdahl had mostly been held in the tribal areas between Pakistan and Afghanistan after what he termed his "dramatic" kidnapping from Afghanistan's Paktika province in June 2009.
Reuters first reported the potential deal involving the five Taliban detainees in December 2011.
While U.S. and Taliban envoys have met directly in the past, there were no direct U.S.-Taliban contacts during the most recent negotiations, U.S. officials said. Messages were passed via Qatari officials.
The final stage of negotiations, which took place in the Qatari capital, Doha, began one week ago, the U.S. officials said. Obama and Qatar's emir spoke on Tuesday and reaffirmed the security conditions under which the Taliban members would be placed, they said. (Additional reporting by Missy Ryan, Roberta Rampton, Mark Hosenball, Will Dunham, David Brunnstrom, Elvina Nawaguna and Patricia Zengerle; Editing by Frances Kerry, Peter Cooney and Alex Richardson)