The Afghan Taliban have freed two Western academics held hostage since 2016 in exchange for three imprisoned senior militants.
American Kevin King and Australian Timothy Weeks were released three years after being kidnapped outside the American University of Afghanistan in Kabul where they worked as professors.
The three militants arrived in Qatar from Afghanistan as part of the swap.
Afghan officials say the deal is aimed at restarting talks with the Taliban.
President Ashraf Ghani said last week the decision was "a tough, but important" one and a "humanitarian gesture".
The swap includes Anas Haqqani, a leading figure and fund-raiser in the Haqqani militant group, and two other senior commanders, who had been held in prison by Afghan authorities.
Anas Haqqani's older brother, Sirajuddin, leads the Haqqani network of fighters and is a deputy leader of the Taliban, which has a political office in Qatar.
The Taliban also announced they had released 10 captured Afghan National Security Force members, saying the prisoner exchange had been "successfully executed".
"These actions are a step forward in good-will and confidence building measures that can aid the peace process," the group said in a statement.
What happened to the professors?
The two professors of English were ambushed by gunmen and taken from a vehicle while leaving their university campus in Kabul in August 2016.
US Navy Seals attempted a rescue mission several days later but Mr Weeks, originally from Wagga Wagga in Australia, and Mr King, from Pennsylvania, had been moved on just hours before.
The pair then appeared in a video, released in January 2017, appealing to then US President-elect Donald Trump to agree to a deal to secure their release.
On Tuesday, a Taliban source in southern Afghanistan told the BBC the pair had been handed over in the Nawbahar district of Zabul province at 10:00 local time (05:30 GMT).
According to a local police officer, who was involved in the swap, a 48-hour ceasefire was observed before the swap. The men were then flown away in a US helicopter.
The condition of the two men remains unclear, but in his speech last week Mr Ghani noted "their health has been deteriorating while in the custody of the terrorists".
The American University of Afghanistan said in a statement that it "shares the relief of the families of Kevin and Timothy, and we look forward to providing all the support we can" to the two men and their families.
Who are the Taliban prisoners?
Anas Haqqani, Haji Mali Khan and Hafiz Rashid were sent to Qatar as part of the exchange.
Haqqani is a leading figure in the Haqqani group, a militant group founded by his father Jalaluddin Haqqani, and now led by his older brother, Sirajuddin, who is also deputy leader of the Taliban, BBC Urdu's Riffat Orakzai says.
Another four of his brothers been killed in various security operations in Pakistan and Afghanistan. The surviving family members are in hiding.
The Haqqani network has been behind many of the co-ordinated attacks on Afghan and Nato forces in recent years and has been blamed for some of the deadliest blasts in the country, including a truck bomb in Kabul in 2017 that killed more than 150 people.
Pakistan has been accused by the West of backing the Haqqani network to counter the influence of arch-rival India in Afghanistan, a charge it denies.
Anas was arrested in Bahrain in 2014. It is believed his captors, the Americans, kept him in a prison in the UAE for some time until he was handed over to the Afghan government in Kabul and imprisoned at Bagram air base.
Hafiz Rashid is a senior Taliban commander who was involved in equipping suicide bombers and helped choose their targets, according to The New York Times. His brother is a member of the Taliban negotiating team in Qatar.
Little is known about Haji Mali Khan, who is said to be a senior commander.
A risky move - or political savvy?
Analysis by Auliya Atrafi, BBC Afghan, Kabul
This is a huge gamble for President Ghani.
The image of Anas Haqqani has been used by critics of the government and civil society protesters to represent the most extreme part of the Taliban - the part responsible for some of the deadliest and most high profile attacks in the heart of Kabul which left hundreds of civilians killed or wounded.
The government recently said releasing him was a red line - but now it's being taunted for having crossed that very line. If this release is followed by a reduction in violence, it could repair the damage, but that remains to be seen.
However, on a positive point: the government managed the deal in a way which made it appear like it was in charge, and not the Americans. To drive this point home, the government seems to have delayed the planned release last week until there was an understanding with the Taliban.
Officials hope this will make the Taliban accept direct talks with the Afghan government - something the militants have always refused up until now.
What happened to previous Taliban hostages?
What happened to the peace talks?
The talks collapsed in September, after President Donald Trump had invited senior Taliban leaders and Afghan president Ashraf Ghani to meet at Camp David, near Washington DC, aiming to end the US' longest war.
But a Taliban attack in the Afghan capital two days earlier, which killed a US soldier and 11 others, prompted Mr Trump to pull out, saying the group "probably don't have the power to negotiate" if they were unable to agree to a ceasefire during talks.
Mr Ghani said in a televised speech that the exchange aimed to "facilitate direct peace negotiations." However, the Taliban have long refused to negotiate with Mr Ghani's administration, calling it a puppet of the US.