Senior officials confirmed his departure on Sunday as the Taliban made further, swift gains in and around the capital.
“To avoid bloodshed, I thought it would be better to leave,” he said on Facebook later on Sunday in his first comments since fleeing.
There were conflicting reports he had flown to Tajikistan or Uzbekistan, although the president’s office said it “cannot say anything about Ashraf Ghani’s movement for security reasons”.
Hamdullah Mohib, the Afghan national security adviser, and a second close associate were with Mr Ghani when he left.
Initial confirmation came from two sources – an official in the office of Afghanistan’s former president, Hamid Karzai, and another an aide on the Afghan security council – who spoke to the Associated Press news agency.
A representative of the Taliban said the group was checking on Mr Ghani’s whereabouts. Militants were later pictured inside the presidential palace as they prepared to announce a Taliban government.
Mr Ghani’s departure – at the end of a week in which the Taliban seized nearly all of Afghanistan, shocking Western military analysts who predicted a much slower advance – signalled the end of a 20-year experiment aimed at remaking Afghanistan.
In his Facebook post, Mr Ghani said he had faced a difficult decision, with the fate of millions of Kabul residents and the security of the city at stake after 20 years of war in which countless numbers had already been killed.
He added that the Taliban insurgents now faced an historic test.
"The Taliban won victory in the judgment of sword and gun and they have responsibility to protect the honour, prosperity and self-respect of our compatriots," he said.
Columbia University-educated Mr Ghani, 72, spent several years living abroad before returning to his home country following the fall of the Taliban in 2001.
He was first elected in 2014 and was re-elected for a second term five years later.
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies