WASHINGTON — The Taliban has freed two Western hostages, American Kevin King and Australian Timothy Weeks, after holding them in captivity for more than three years, a U.S. official and the Pakistani prime minister said Tuesday.

A U.S. official with knowledge of the release said the American University of Kabul professors, who were kidnapped at gunpoint in August 2016, were now in U.S. hands. Their health was being evaluated and the two were being debriefed, according to the official who was not authorized to speak to the media on the subject.

"We appreciate steps taken by all involved to make it possible," Pakistani Prime Minister Imran Khan said via Twitter. "As part of the international community working to bring peace and end the suffering of the Afghan people, Pakistan has fully supported and facilitated this release as part of its policy of supporting initiatives for a negotiated political settlement of the Afghan conflict."

Taliban sources said the two hostages had been handed over in Zabul province, on the border with Pakistan. The Taliban said 10 Afghan soldiers had also been released.

King was suffering from “serious” and “multiple” health issues, according to a Taliban leader in Zabul province.

“The American teacher was having some serious health problems when we handed him over to the U.S. and Afghan officials,” he added, speaking on the condition of anonymity because he was not authorized to speak to the press.

On Nov. 12, Afghan President Ashraf Ghani announced the deal to release the two hostages in exchange for three Taliban members.

The Western hostages were released in exchange for Taliban members Anas Haqqani, Haji Maali Khan and Hafiz Rasheed Ahamd Omari, according to the Taliban.

Australian Prime Minister Scott Morrison confirmed the professors' release too.

“Tim’s family has asked for privacy. They have asked the Australian Government to convey their relief that their long ordeal is over, and their gratitude to all those who have contributed to Tim’s safe return,” he added on Twitter.

The American University of Afghanistan welcomed the news.

“The AUAF community shares the relief of the families of Kevin and Timothy, and we look forward to providing all the support we can to Kevin and Tim and their families,” the statement said.

The exchange raises hopes that negotiations between the U.S. and the Taliban may restart after President Donald Trump pulled the plug on a potential deal to begin withdrawing U.S. troops from the country and end America's longest war. Negotiations broke down Sept. 7 and it remains unclear if and when they will start again.

“These actions are a step forward in goodwill and confidence building measures that can aid the peace process,” the Taliban said in a statement Tuesday.

Abigail Williams reported from Washington; Ahmed Mengli reported from Kabul; Mushtaq Yusufzai from Peshawar, Pakistan; and Saphora Smith from London.