President Barack Obama speaks with Jani Bergdahl, left, and Bob Bergdahl, right, the parents of U.S. Army Sgt. Bowe Bergdahl, in the Rose Garden of the White House in Washington, Saturday, May 31, 2014, after the announcement that Bowe Bergdahl has been released from captivity. Bergdahl, 28, had been held prisoner by the Taliban since June 30, 2009. He was handed over to U.S. special forces by the Taliban in exchange for the release of five Afghan detainees held by the United States. (AP Photo/Carolyn Kaster)

President Barack Obama speaks with Jani Bergdahl, left, and Bob Bergdahl, right, the parents of U.S. Army Sgt. Bowe Bergdahl, in the Rose Garden of the White House in Washington, Saturday, May 31, 2014, after the announcement that Bowe Bergdahl has been released from captivity. Bergdahl, 28, had been held prisoner by the Taliban since June 30, 2009. He was handed over to U.S. special forces by the Taliban in exchange for the release of five Afghan detainees held by the United States. (AP Photo/Carolyn Kaster)

Buy AP Photo Reprints

WASHINGTON (AP) â€” The only American soldier held prisoner in Afghanistan has been freed by the Taliban in exchange for the release of five Afghan detainees from the U.S. prison at Guantanamo Bay, Cuba, Obama administration officials said Saturday.

Sgt. Bowe Bergdahl was handed over to U.S. special operations forces by the Taliban Saturday evening, local time, in an area of eastern Afghanistan, near the Pakistani border. Officials said the exchange was not violent and the 28-year-old Bergdahl was in good condition and able to walk.

“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 (AWOL) or desertion.

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