At a press event broadcast live on state television, Ghani told the nation that the "conditional release" was a very hard decision he felt he had to make in the interest of the Afghan people.
The announcement comes at a sensitive time for Ghani, as President Donald Trump halted talks between the U.S. and the Taliban in September, after a particularly deadly spate of Taliban attacks, including a Kabul suicide bombing that killed a U.S. soldier. Also, the future of Ghani's government is in doubt as the results from the Sept. 28 presidential elections have not been released yet. Preliminary results are expected on Thursday.
The three members of the Taliban-linked Haqqani network that Ghani said were being released include Anas Haqqani, Haji Mali Khan and Hafiz Rashid. Ghani added that they are being released "conditionally in exchange" for the two professors.
By mid-afternoon, no visuals had emerged of the three figures. It was not immediately clear if they were still in Afghanistan, on their way or had already been sent — for example — to Qatar, where the Taliban maintain a political office.
There was also no statement from the Taliban or the Haqqani faction holding the American and Australian hostages, or any indication if and where the two would be freed.
Australia's Department of Foreign Affairs and Trade said it appreciated Ghani's concern for American Kevin King and Australian Timothy Weeks and expressed hope the Taliban would immediately releases the hostages.
"The Australian government has never stopped pressing for their release, but we will not give a running commentary on the current process," a department statement said.
"The Afghan government is leading the discussions with the Taliban for Mr. Weeks' and Mr. King's release as part of its broader peace negotiations," it added.
The three Taliban figures were under the custody of the Afghan government, Ghani said, and were held at the Bagram prison, an air base that also houses U.S. troops just outside Kabul.
"In a demonstration of respect for humanity by the government and nation of Afghanistan, we decided to conditionally release these three Taliban prisoners who were arrested in close cooperation with our international partners from other countries," Ghani said, without elaborating.
The Taliban have long demanded the release of Anas Haqqani, the younger brother of Sirajuddin, the deputy head of the Taliban and leader of the Haqqani network, often considered the strongest of the Taliban factions fighting in Afghanistan.
Anas Haqqani was arrested in Bahrain in 2014 and handed over to the Afghan government, which later sentenced him to death. It was not clear when his execution was supposed to take place.
The two captives held by the Taliban were abducted in 2016 outside the American University in Kabul where they both work as teachers.
The following year, the Taliban released two videos showing the captives. A January 2017 video showed them appearing pale and gaunt. In the later video, King and Weekes looked healthier and said a deadline for their release was set for June 16 that year.
Both said they are being treated well by the Taliban but that they remain prisoners and appealed to their governments to help set them free. It was impossible to know whether they were forced to speak.
Subsequently, U.S. officials said that American forces had launched a rescue mission to free the two, but the captives were not found at the raided location.
In Tuesday's address, Ghani added that the Taliban kidnapping of the two American University teachers was not representative of Islamic and Afghan traditions.
"We have decided to release these three Taliban prisoners who were arrested outside of Afghanistan," Ghani said, adding that it was meant "to facilitate direct peace negotiations."
In a statement, the American University of Afghanistan said it welcomed the development and was "encouraged to hear reports of the possible release of our two colleagues, Kevin King and Timothy Weeks."
The statement added that while the university was not part of any negotiations with the Taliban or government discussions, it continues "to urge the immediate and safe return of our faculty members who have been held in captivity, away from their friends and families, for more than three years."
Ghani said the release of the teachers was "part of our main demands during the indirect negotiations with the Taliban."
"We can assure the families of both teachers that we welcome and honor those who come to our country to pursue education," Ghani said.
Meanwhile, talks are underway about another round of so-called "intra-Afghan dialogue," this time in Beijing, which would include a wide selection of Afghan figures and Taliban representatives. The meeting was initially to take place last month but has been postponed with no new date set. The last time it was held was in July in Qatar.
The dialogue is a separate process from the U.S.-Taliban talks under U.S. peace envoy Zalmay Khalilzad that collapsed in September.
The Taliban have refused to talk directly with the Kabul government while Ghani insists his government must lead any talks with the Taliban.
Associated Press writers Tameem Akhgar in Kabul, Afghanistan, and Rod McGuirk in Canberra, Australia, contributed to this report.
This story has been corrected to show that the American and Australian professor were abducted in 2016, not 2017, and that Weeks was the spelling of the Australian's surname.