(CNN) -

Sgt. Bowe Bergdahl, the American soldier held captive for nearly five years by militants during the Afghanistan war, has been released in an apparent swap for Guantanamo detainees, authorities said Saturday.

"Today the American people are pleased that we will be able to welcome home Sergeant Bowe Bergdahl," the White House said in a statement.

Secretary of Defense Chuck Hagel said in a separate statement that he had informed Congress of the decision to transfer five detainees from Guant√°namo Bay to Qatar.

"A few hours ago, the family of Sgt. Bowe Bergdahl was informed by President Obama that their long wait for his return will soon be over," Hagel said.

"Sgt. Bergdahl is now under the care of the U.S. military after being handed over by his captors in Afghanistan. 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."

A statement from Bergdahl's parent's read, "We were so joyful and relieved [when] President Obama called us today to give us this news that Bowe is finally coming home. We cannot wait to wrap our arms around our only son."

A senior Defense official told CNN that the U.S. military recovered Berghdahl from his captors around 10:30 a.m. ET in a peaceful handover in eastern Afghanistan. U.S. special operations forces conducted the rescue.

The official said that once on the U.S. helicopter, Berghdal wrote on a paper plate, "SF?" meaning, "Special Forces?" He wrote because of the noise. The operators sitting with Bergdahl responded loudly, saying, "Yes, we've been looking for you for a long time." Berghdal broke down crying, the official recounted.

In exchange for Bergdahl's release, five detainees at Guantanamo Bay will be released to Qatar. The US has "appropriate assurances" that Qatar will be able to secure the detainees there. They are under a travel ban for a year.

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 transfer was brokered through the local Qatari government, the official said. Talks for the transfer began about a week ago.

Bergdahl's parents happened to still be in Washington, in town for Memorial Day.

Bergdahl, 28, was being held at a forward operating base in Afghanistan.

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 White House said, "On behalf of the American people, I was honored to call his parents to express our joy that they can expect his safe return, mindful of their courage and sacrifice throughout this ordeal."

Bergdahl was deployed to Afghanistan in May 2009 and captured by the Taliban 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.