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.