US President Barack Obama says he received security guarantees from Qatar over five Guantanamo Bay prisoners who were transferred to secure the release of a US soldier in Afghanistan.
US Army Sergeant Bowe Bergdahl, 28, was handed to US forces after being held for nearly five years by the Taliban.
He has left Afghanistan and is en route to a US military hospital in Germany.
Five Afghan detainees were released from the US prison in Cuba and handed to Qatar, which mediated the deal.
Sgt Bergdahl, who is said to be in good condition, was the only US soldier being held by the Taliban in Afghanistan.
His parents said they were “joyful and relieved” to hear of their son’s release.
Hours after the release, President Obama told reporters the Qatari government had given the US assurances “that it will put in place measures to protect our national security”.
He also thanked the Qatari authorities for their role in acting as a go-between during indirect US-Taliban negotiations that led to the deal.
The exchanged prisoners are thought to be the most senior Afghans still held at Guantanamo. Under the deal, they will be banned from leaving Qatar for at least a year.
The Taliban said they welcomed their release with “great happiness”.
“While Sgt Bergdahl was gone he was never forgotten,” President Obama said, adding that the US had an “ironclad commitment” to bringing home its prisoners of war.
He was joined by Sgt Bergdahl’s parents, Robert and Jani, at the White House on Saturday. They offered thanks to those who took part in securing their son’s freedom.
In an emotional speech, Robert Bergdahl said his son was having trouble speaking English after his rescue.
The BBC’s Beth McLeod in Washington says the soldier is being taken to a US military medical centre in Germany, where he will receive medical treatment and begin the process of reconnecting with his family through telephone calls and video conferences.
Mohammad Fazl served as the Taliban’s deputy defence minister during America’s military campaign in 2001. Accused of possible war crimes, including the murder of thousands of Shia Muslims.
Khirullah Khairkhwa was a senior Taliban official serving as interior minister and governor of Herat, Afghanistan’s third largest city. Alleged to have had direct links to Osama bin Laden.
Abdul Haq Wasiq was the Taliban’s deputy minister of intelligence. Said to have been central in forming alliances with other Islamic fundamentalist groups to fight against US and coalition forces.
Mullah Norullah Noori was a senior Taliban military commander and a governor. Also accused of being involved in the mass killings of Shia Muslims.
Mohammad Nabi Omari held multiple Taliban leadership roles, including chief of security. Alleged to have been involved in attacks against US and coalition forces.
Officials said the Taliban had handed Sgt Bergdahl over on Saturday evening, local time, in eastern Afghanistan, in an exchange that involved several dozen US special forces.
A senior official told the BBC that, once aboard the US helicopter, Sgt Bergdahl wrote “SF?” – asking if they were special operations forces – on a paper plate and showed it to the pilots, who replied: “Yes, we’ve been looking for you for a long time.”
The senior official said: “At that point, Sgt Bergdahl broke down”.
The soldier, of Hailey, Idaho, was captured on 30 June 2009, about two months after arriving in eastern Afghanistan.
In January, the US military obtained a new video of Sgt Bergdahl, giving his family renewed hope of his eventual return.
Throughout his captivity, the soldier’s hometown had continued to remember him with special events and yellow ribbons tied to poles and trees.
On Saturday, family friend in Hailey, Stefanie O’Neill, told Reuters: “I’m beyond thrilled. It’s probably the happiest day of my life, besides when my two kids were born.”
She said a Bring Bowe Back vigil planned for 28 June would now be called Bowe is Back.