(CNN) -- President Barack Obama, flanked by the parents of Sgt. Bowe Bergdahl at the White House on Saturday, praised the diplomatic officials and troops who helped secure the release of the American soldier held captive for nearly five years by militants during the Afghanistan war.
Bergdahl was released in exchange for five Guantanamo detainees, officials said.
The government of Qatar, which helped broker the release, pledged to "put in place measures to protect our national security," Obama said at the White House Rose Garden.
"While Bowe was gone, he was never forgotten," the President said.
Bergdahl's mother, Jani, said, "We will continue to stay strong for Bowe while he recovers."
Bob Bergdahl said he was not sure whether his son still speaks English and spoke at one point in what appeared to be Pashtun.
"I'm your father, Bowe," the father said.
Members of the White House national security team -- including Chief of Staff Denis McDonough, National Security Adviser Susan Rice and counterterrorism adviser Lisa Monaco -- grew emotional when the parents thanked those who helped secure their son's release.
Bergdahl, the only remaining U.S. soldier captured during the conflicts in Iraq and Afghanistan, was recovered by U.S. special operations forces without incident about 10:30 a.m. ET at a "pick-up" point in eastern Afghanistan, near the border with Pakistan, a senior Department of Defense official told CNN. There were 18 armed Taliban members present.
Once he was on an American helicopter, Bergdahl, 28, used a paper plate to communicate because of the noise. He wrote, "SF?" meaning, "special forces?"
One of the operators sitting with Bergdahl responded loudly: "Yes, we've been looking for you for a long time," according to the official.
Bergdahl broke down crying.
'Cannot wait to wrap our arms around our only son'
Earlier, the White House said in a statement, "Today the American people are pleased that we will be able to welcome home Sergeant Bowe Bergdahl."
Secretary of Defense Chuck Hagel said that he had informed Congress of the decision to transfer five detainees from Guantanamo Bay to Qatar in exchange for Bergdahl, who was the only remaining American soldier captured from conflicts in Iraq and Afghanistan.
After Bergdahl was handed over, a series of secret procedures were set in motion so each side knew the other was living up to the bargain, according to U.S. Defense officials. Qatari officials were already at Guantanamo and took custody of the detainees. They assured the Taliban that the detainees would be flown to Qatar.
The Afghan Taliban issued a statement on its website in Arabic and Pashto announcing with "great happiness and joy" the exchange of Bergdahl for five of its imprisoned senior leaders.
It said, "The Islamic Emirate of Afghanistan was and has been for a long time attempting to free all the imprisoned Afghan prisoners inside and outside the country."
"Sgt. Bergdahl is now under the care of the U.S. military after being handed over by his captors in Afghanistan," Hagel said. "We will give him all the support he needs to help him recover from this ordeal, and we are grateful that he will soon be reunited with his family."
Bergdahl's parents happened to still be in Washington, having visited for Memorial Day.
They said in an earlier statement: "We were so joyful and relieved when President (Barack) Obama called us today to give us the news that Bowe is finally coming home! We cannot wait to wrap our arms around our only son. We want to thank Bowe's many supporters in Idaho, around the nation and around the world. We thank the Amir of Qatar for his efforts. And of course, we want to take this opportunity to thank all those in the many U.S. Government agencies who never gave up. Today, we are ecstatic!"
Secretary of State John Kerry said the "cost of years of captivity to Sergeant Bowe Bergdahl and his family is immeasurable."
'Appropriate assurances' over five detainees
In exchange for Bergdahl's release, five detainees at Guantanamo Bay will be released to Qatar, authorities said. The United States has "appropriate assurances" that Qatar will be able to secure the detainees there, where they are under a travel ban for a year.
A U.S. Air Force aircraft carrying the detainees left the U.S. Navy base in Cuba on Saturday afternoon, a senior Defense official told CNN.
Bergdahl was first transferred to Bagram Airfield, the main U.S. base in Afghanistan, for medical evaluation.
"His health is our number one priority at this time," a senior U.S. defense official said.
Saturday night, Bergdahl was en route from Bagram to Landstuhl Regional Medical Center in Germany, a senior defense official told reporters traveling with Hagel.
His "reintegration process" will include "time for him to tell his story, decompress, and to reconnect with his family through telephone calls and video conferences. At this time we believe that he will physically reunite with his family in Texas," the official said.
Hagel said the United States "coordinated closely with Qatar to ensure that security measures are in place and the national security of the United States will not be compromised."
The United States believes Bergdahl had been held for the bulk of his captivity in Pakistan, the official said. It was unclear when he was moved to Afghanistan.
The U.S. government acknowledged in May 2012 that it was engaged in talks with the Taliban to free Bergdahl.
Saturday's transfer was brokered through the local Qatari government, the official said, after talks that began about a week ago.
U.S. officials had said this year that one route to getting Bergdahl back was through Qatari officials, who had been talking to the Taliban. But Bergdahl was believed to be held by operatives from the Haqqani network, an insurgent force affiliated with the Taliban and al Qaeda, and it was not clear whether Haqqani operatives would abide by any agreement among the United States, Qatar and the Taliban.
An Afghan Taliban commander, not authorized to speak to the media, confirmed to CNN that Bergdahl was captured by the Afghan Taliban with links to the Haqqani network in Pakistan. Over the years, the captive was transferred back and forth between Afghanistan and Pakistan.
Bergdahl was deployed to Afghanistan in May 2009. He was 23 when he was captured by the Taliban after finishing a guard shift at a combat outpost on June 30, 2009, in Paktika province.
In July of that year, a U.S. military official said the soldier was being held by the clan of warlord Siraj Haqqani.
Critics question the negotiations
The United States has long declared that it won't negotiate with groups linked to terrorists, but analysts have said the United States has effectively maneuvered around the edges of that declaration over the years.
"As the administration has repeatedly affirmed, we will not transfer any detainee from Guantanamo unless the threat the detainee may pose to the United States can be sufficiently mitigated and only when consistent with our humane treatment policy," a senior administration official told CNN, adding that the detainees will be "subject to restrictions on their movement and activities."
Arizona Sen. John McCain, a former POW, in a statement called the released detainees "hardened terrorists who have the blood of Americans and countless Afghans on their hands."
"I am eager to learn what precise steps are being taken to ensure that these vicious and violent Taliban extremists never return to the fight against the United States and our partners or engage in any activities that can threaten the prospects for peace and security in Afghanistan," he said. "The American people, and our Afghan partners, deserve nothing less."
A senior administration official told CNN, "With regard to whether or not we're negotiating with terrorists: Sergeant Bergdahl is a member of the military who was detained during the course of an armed conflict. The transfer of these individuals is not a concession -- it is fully in line with the President's goal of closing the detention facility at Guantanamo Bay."
The Taliban had long demanded the release of five detainees at the U.S. military prison at Guantanamo Bay, Cuba. But U.S. officials said that releasing them would be difficult because Congress would have to be notified in advance, and lawmakers have previously resisted releasing them.
NATO leaders signed off last week on Obama's exit strategy from Afghanistan that calls for an end to combat operations next year and the withdrawal of the U.S.-led international military force by the end of 2014.
Bergdahl, of Wood River Valley, Idaho, appeared in diminished health in a video that the U.S. military obtained in January. His family also received a letter from him last year via the Red Cross.
CNN's Erin McPike, Elise Labott, Ed Lavendara, Sophia Saifi in Islamabad and journalist Zahir Shah Sherazi in Peshawar contributed to this report.