PESHAWAR, Pakistan/KABUL (Reuters) - The Afghan Taliban on Tuesday released American and Australian university professors held hostage for more than three years, officials of the three nations said, completing a delayed prisoner swap and raising hopes for a revival of peace talks.

American Kevin King and Australian Timothy Weeks, kidnapped in August 2016 outside Kabul’s American University of Afghanistan, where both worked, were freed in return for the release of three Taliban commanders, Afghan officials said.

“Our family is overjoyed that Tim has been released after more than three years in captivity,” Weeks’ family said in an emailed statement released by Australia’s foreign ministry.

The U.S.-backed Afghan government’s decision to carry out the swap is seen as key to securing direct talks with the Islamist militants, who have, until now, refused to engage with what they call an illegitimate “puppet” regime in Kabul.

Talks between the Taliban and the United States aimed at ending their 18-year war collapsed in September after President Donald Trump called off what he described as a planned meeting at the U.S. Camp David presidential retreat.

Earlier on Tuesday, three Taliban sources familiar with the deal, including one in Qatar, home to the political leadership of the Afghan Taliban, said the three Taliban commanders who were part of the swap were freed from jail in Afghanistan.

The United States and Australia confirmed the release, voicing hope that, along with other developments, it might improve chances for dialogue between the Afghans, and an eventual peace agreement.

“The Taliban have indicated that the release of the two professors is intended as a goodwill gesture, which the United States welcomes,” U.S. Secretary of State Mike Pompeo said in a statement, adding the men were in the care of the U.S. military.

Pompeo also said he welcomed the Afghan government’s release of the three Taliban prisoners and the “Taliban’s impending release of 10 Afghan prisoners” but gave no details.

“We see these developments as hopeful signs that the Afghan war, a terrible and costly conflict that has lasted 40 years, may soon conclude through a political settlement,” Pompeo added.

He dated the start of the Afghan conflict to the Soviet invasion in 1979, rather than the U.S. invasion after the Sept. 11, 2001 attacks on the United States.

“Along with a reduction of violence in Kabul during the past few days, the above developments give us hope for the success of intra-Afghan peace negotiations, which the United States stands ready to support,” Pompeo added.

Australian Prime Minister Scott Morrison said Weeks was receiving medical care, but declined to provide details.

Slideshow ( 5 images )

“He’s in good condition and he’s currently going through all of those assessments, as you’d expect,” Morrison told broadcaster Channel 7.

“We couldn’t be more pleased to finally get them out safely and to get them home to their families.”

On Nov. 12, President Ashraf Ghani said Afghanistan would free Anas Haqqani, a senior figure in the eponymous Haqqani network, a militant faction of the Taliban responsible for some of the worst violence in recent years, and two Taliban commanders. [L4N27S1DV]

Slideshow ( 5 images )

But the swap was abruptly postponed, with the Taliban then shifting their hostages to a new location. [L4N27V37L]

The Haqqani network, which has targeted Afghan civilians, is believed to be based in Pakistan and is part of the Taliban in Afghanistan.

The United States and the Taliban spent much of the past year discussing a plan for the withdrawal of U.S. troops in exchange for Taliban security guarantees. But Trump halted the talks following the death of a U.S. soldier and 11 people in a Taliban bomb attack in Kabul.

Before the talks were broken off, both sides had said they were close to a deal.