He said he had not intended to abandon his people but “it was the only way”.
“Leaving Kabul was the most difficult decision of my life,” he said, adding that he was sorry he “could not make it end differently”.
In a statement shared on Twitter on Wednesday, Mr Ghani said he had no choice but to leave the country in order to avoid widespread violence.
“I left at the urging of the palace security, who advised me that to stay risked setting off the same street-to-street fighting the city had suffered during the civil war of the 1990s,” he wrote, adding that he did so to “save Kabul and her six million citizens”.
He said he had devoted 20 years to helping Afghanistan become a “democratic, prosperous and sovereign state”.
Mr Ghani added that he had “deep and profound regret that my own chapter ended in similar tragedy to my predecessors”.
The 72-year-old former president, who has faced intense criticism from other Afghan politicians for leaving the country, said he would address the “events leading up to my departure” in the near future.
In a live Facebook address on 18 August, Mr Ghani said he was “forced” to leave Afghanistan by his security team because “there was a real chance that I would be captured and killed”.
He said that when the Taliban entered the presidential palace in Kabul, “they started looking for me from room to room”.
He also again denied the “baseless” allegations that he had travelled to the UAE with about $169m.
Denying claims that he had taken a large amount of money with him when he left the country, Mr Ghani said he was “not even allowed to take my sandals off and put my shoes on”.
Earlier this week the Taliban, which seized control of Afghanistan in a sweeping offensive more than three weeks ago, announced the formation of an all-male interim government to rule the country.
Meanwhile, China has pledged 200 million yuan ($31m) worth of aid to Afghanistan, including food supplies and coronavirus vaccines.
The aid comes as Beijing said it was ready to maintain communication with the Taliban government.
It added that the establishment of the new interim government was a “necessary step to restore order” in Afghanistan.
The Taliban’s interim cabinet was announced last week, with the country declared an “Islamic Emirate”.
Chinese Foreign Minister Wang Yi announced the aid measures for Afghanistan at a meeting on Wednesday, with counterparts from several of Afghanistan’s neighbours – Pakistan, Iran, Tajikistan, Uzbekistan and Turkmenistan.
He called on these countries to cooperate in helping Afghanistan, adding that China would also provide 3 million vaccine doses to the country.
China has also been vocally critical about the US’ withdrawal, saying its troops had “wrecked havoc” in Afghanistan.
A Chinese state official said the US had inflicted “serious damage on the Afghan people from the very first day of its invasion to the last minute of its withdrawal”.
“What the US did in Afghanistan over the past two decades is a textbook example which shows us the consequences of wanton military intervention and attempts to impose one’s own ideology and values on others,” said Foreign Ministry Spokesperson, Wang Wenbin.
Taliban officials have described China as Afghanistan’s most important partner and pinned hopes on Chinese investment and support to rebuild the war-torn country.
Beijing has made serious efforts to establish good relations with the Taliban.
Even before the Taliban took control of Afghanistan, China invited representatives of the group over for talks in July, offering economic support for Afghanistan but also stressing that the country should not be used as a staging point for terrorists.
However, Beijing has struggled to sell this cautious alliance to some parts of the Chinese public that are repulsed by the Taliban.