"While Bowe was gone, he was never forgotten," President Barack Obama said in a statement from the White House Rose Garden, where he was joined by Bergdahl's parents. "The United States of America does not ever leave our men and women in uniform behind."
Bergdahl's handover followed indirect negotiations between the U.S. and the Taliban, with the government of Qatar serving as the go-between. Qatar is taking custody of the five Afghan detainees who were held at Guantanamo.
Several dozen U.S. special operations forces, backed by multiple helicopters and surveillance aircraft, flew into Afghanistan by helicopter and made the transfer with the approximately 18 Taliban members. Officials said the commandos were on the ground for a short time before lifting off with Bergdahl.
According to a senior defense official, once Bergdahl climbed onto the noisy helicopter, he took a pen and wrote on a paper plate, "SF?" asking the troops if they were special operations forces.
They shouted back at him over the roar of the rotors: "Yes, we've been looking for you for a long time."
Then, according to the official, Bergdahl broke down.
Bergdahl, of Hailey, Idaho, is believed to have been held by the Haqqani network since June 30, 2009. Haqqani operates in the Afghanistan-Pakistan border region and has been one of the deadliest threats to U.S. troops in the war.
The network, which the State Department designated as a foreign terrorist organization in 2012, claims allegiance to the Afghan Taliban, yet operates with some degree of autonomy.
Officials said Bergdahl was initially taken to Bagram Air Field, the main U.S. base in Afghanistan, for medical evaluations, and was being transferred to Landstuhl Regional Medical Center, a military facility in Germany, for additional care before he returns to the United States.
The official said Bergdhal was tentatively scheduled to go to the San Antonio Military Medical Center where he would be reunited with his family. The military was working Saturday to connect Bergdahl with his family over the telephone or by video conference.
The U.S. believes Bergdahl was held for the bulk of his captivity time in Pakistan, but officials said it was not clear when he was transported to eastern Afghanistan.
All of the officials insisted on anonymity in order to discuss details of Bergdahl's transfer.
Bergdahl's parents, Bob and Jani, had been in Washington on a previously scheduled visit when they received a call Saturday from Obama informing them that their son had been freed.
As they stood with Obama in the Rose Garden hours after their son's release, Bob Bergdahl, who grew a long, thick beard to honor his son, said Bowe Bergdahl was having trouble speaking English after his rescue. The elder Bergdahl had worked to learn Pashto, the language spoken by his son's captors, and delivered him a message in that language.
Switching back to English, he said "the complicated nature of this recovery will never really be comprehended."
The circumstances surrounding Bergdahl's capture remain something of a mystery. There has been some speculation that he willingly walked away from his unit, raising the question of whether he could be charged with being absent without leave or desertion. A senior U.S. official told The Associated Press on Saturday that the Army would make the decision on any charges but that the feeling at the moment was that Bergdahl had suffered enough in his ordeal. The official was not authorized to discuss the matter by name and requested anonymity.
In 2012, Rolling Stone magazine quoted emails Bergdahl is said to have sent to his parents that suggest he was disillusioned with America's mission in Afghanistan, had lost faith in the U.S. Army's mission there and was considering desertion. Bergdahl told his parents he was "ashamed to even be American."
The Associated Press could not independently authenticate the emails.
Were Bergdahl to be charged with desertion, the maximum penalty he would face is five years in prison and a dishonorable discharge, if it's proven that he deserted with the intent to avoid hazardous duty or to shirk important service. A case of AWOL, ended by the U.S. apprehending him, would not require proof that he intended to remain away permanently. The maximum punishment for that would be a dishonorable discharge and 18 months' confinement, according to military justice experts.
The U.S. has long been seeking Bergdahl's release, but there was renewed interest in his release as Obama finalized plans to pull nearly all American forces out of Afghanistan by the end of 2016.
Officials said the Taliban signaled to the U.S. in November that they were ready to start new talks on the issue of detainees. After the U.S. received proof that Bergdahl was still alive, indirect talks began, with Qatar sending messages back and forth between the two parties.
The talks intensified about a week ago, officials said, resulting in Bergdahl's release and the transfer of the Afghan detainees.
The senior U.S. official said those U.S. officials involved in the swap decided it could further the effort to reach reconciliation with the Taliban, which they see as a key to achieving a higher level of security in Afghanistan. They acknowledged in their discussions the question of emboldening other insurgent groups to take troops or other Americans prisoner to secure the release of other prisoners, according to the official. The military believed that Bergdahl's status as a prisoner of war obliged doing whatever possible to obtain his release, the official said.
The five Guantanamo detainees departed the base on a U.S. military aircraft Saturday afternoon. Under the conditions of their release, the detainees will be banned from traveling outside of Qatar for at least one year.
Obama and the emir of Qatar spoke last week about the conditions of the release, which have been codified in a memorandum of understanding between the two countries, officials said.
The administration is legally required to notify Congress in advance about plans to release Guantanamo detainees. An administration official said lawmakers were notified only after U.S. officials knew they had Bergdahl, but before the transfers took place.
Two Republican lawmakers said Obama violated U.S. laws when he approved the exchange. Rep. Howard "Buck" McKeon of California and Sen. James Inhofe of Oklahoma said the law required Obama to notify Congress 30 days before any transfer of terrorists from the U.S. detention facility at Guantanamo Bay, Cuba. In response, the White House said that officials considered what they called "unique and exigent circumstances" and decided to go ahead with the transfer in spite of the legal requirement.
The detainees are among the most senior Afghans still held at the prison. They are:
Abdul Haq Wasiq, who served as the Taliban deputy minister of intelligence
Mullah Norullah Nori, a senior Taliban commander in the northern city of Mazar-e-Sharif when the Taliban fought U.S. forces in late 2001
Khairullah Khairkhwa, who served in various Taliban positions including interior minister and had direct ties to Mullah Omar and Osama bin Laden
Mohammed Nabi, who served as chief of security for the Taliban in Qalat, Afghanistan, and later worked as a radio operator for the Taliban's communications office in Kabul
Mohammad Fazl, whom Human Rights Watch says could be prosecuted for war crimes for presiding over the mass killing of Shiite Muslims in Afghanistan in 2000 and 2001 as the Taliban sought to consolidate their control over the country.
In a statement on the Taliban website that was translated by the Washington-based SITE Intelligence Group, the Taliban announced the exchange with "great happiness and joy" and said it "was and has been for a long time attempting to free all the imprisoned Afghan prisoners inside and outside the country, and restoring the right of freedom to them quickly."
The Taliban said it is seeking the release of additional prisoners but offered no specifics. It also said the five released detainees would be received by members of its political office in Qatar. That office was reportedly closed last year after a dispute with Afghan President Hamid Karzai, and its role in the exchange may be an indication that it is functioning.
In Pakistan, Foreign Ministry spokeswoman Tasnim Aslam said her government was "not aware of" Bergdahl's release or the negotiations leading up to it. She declined to comment further.
Baldor reported from Singapore. Associated Press writers Deb Riechmann and Darlene Superville in Washington, Rahim Faiez in Kabul, Afghanistan, and Zarar Khan in Islamabad contributed to this report.