Afghanistan’s embattled President Ashraf Ghani has fled the country as the Taliban moved further into the capital city, Kabul.

His countrymen and foreigners alike raced for the exit, signalling the end of a 20-year Western experiment aimed at remaking Afghanistan.

Ghani flew out of the country, two officials told the Associated Press, speaking on condition of anonymity as they were not authorised to brief journalists. Abdullah Abdullah, the head of the Afghan National Reconciliation Council, later confirmed Ghani had left in an online video.

“He left Afghanistan in a hard time, God hold him accountable,” Abdullah said.

Afghanistan
Afghan President Ashraf Ghani is reported to have fled the country (Rahmat Gul/AP)

Civilians fearing that the Taliban could reimpose the kind of brutal rule that all but eliminated women’s rights rushed to leave the country, lining up at cash machines to withdraw their life savings.

Helicopters buzzed overhead to evacuate personnel from the US Embassy, while smoke rose near the compound as staff destroyed important documents. Several other Western missions also prepared to pull their people out.

In a stunning rout, the Taliban seized nearly all of Afghanistan in just over a week, despite the billions of dollars spent by the US and Nato over nearly two decades to build up Afghan security forces.

Just days earlier, an American military assessment estimated it would be a month before the capital would come under insurgent pressure.

Instead, the Taliban swiftly defeated, co-opted or sent Afghan security forces fleeing from wide swaths of the country, even though they had some air support from the U.S. military.

A US Chinook helicopter flies over the US embassy in Kabul, Afghanistan
A US Chinook helicopter flies over the US embassy in Kabul, Afghanistan (Rahmat Gul/AP)

On Sunday, the insurgents entered the outskirts of Kabul but apparently remained outside of the city centre. Sporadic gunfire echoed at times though the streets were largely quiet.

Taliban spokesman Suhail Shaheen told Qatar’s Al-Jazeera English satellite news channel that the insurgents are “awaiting a peaceful transfer of Kabul city”. He declined to offer specifics on any possible negotiations between his forces and the government.

But when pressed on what kind of agreement the Taliban wanted, Shaheen acknowledged that they were seeking an unconditional surrender by the central government.

Taliban negotiators headed to the presidential palace on Sunday to discuss the transfer, said an Afghan official who spoke on condition of anonymity for fear of reprisals.

The negotiators on the government side included former President Hamid Karzai and Abdullah Abdullah, the head of the Afghan National Reconciliation Council, an official said.

The US embassy buildings in Kabul, Afghanistan
The US embassy buildings in Kabul (Rahmat Gul/AP)

The official, who spoke on condition of anonymity to discuss details of the closed-doors negotiations, described them as “tense”. Karzai himself appeared in a video posted online, his three young daughters around him, saying he remained in Kabul.

“We are trying to solve the issue of Afghanistan with the Taliban leadership peacefully,” he said, while the roar of a passing helicopter could be heard overhead.

Abdullah has been a vocal critic of President Ashraf Ghani, who long refused giving up power to get a deal with the Taliban.

Ghani appeared increasingly isolated. Warlords he negotiated with just days earlier have surrendered to the Taliban or fled, leaving him without a military option. Negotiations in Doha, Qatar, the site of a Taliban office, have failed to stop the insurgents’ advance.

Still, acting Defence Minister Bismillah Khan sought to reassure the public that Kabul would remain “secure”. The insurgents also tried to calm residents of the capital, insisting their fighters would not enter people’s homes or interfere with businesses. They also said they would offer an “amnesty” to those who worked with the Afghan government or foreign forces.

A man sells Taliban flags in Herat province, west of Kabul, Afghanistan
A man sells Taliban flags in Herat province, west of Kabul (Hamed Sarfarazi/AP)

“No one’s life, property and dignity will be harmed and the lives of the citizens of Kabul will not be at risk,” the insurgents said in a statement.

But there have been reports of revenge killings and other brutal tactics in areas of the country the Taliban have seized in recent days.

And on Sunday, panic set in as many rushed to leave the country through the Kabul airport, the last route out of the country as the Taliban now hold every border crossing.

One young woman who lives in Herat province expressed despair at the prospect of a Taliban government.

“Having devoted my life to the fight for the rights of women, it is very difficult to accept that all my efforts will be buried under the ground,” said the 25-year-old who works for a non-governmental organisation. She spoke on condition of anonymity because she feared for her safety.

Smoke rises next to the US embassy in Kabul, Afghanistan
Smoke rises next to the US embassy in Kabul (Rahmat Gul/AP)

Rapid shuttle flights of helicopters near the US Embassy began on Sunday, a few hours after the militants seized the nearby city of Jalalabad — which had been the last major city besides the capital not in Taliban hands.

The US decided a few days ago to send in thousands of troops to help evacuate some personnel, and two officials said on Sunday that American diplomats were being moved from the embassy to the airport.

Military helicopters shuttled between the embassy compound and the airport, where a core presence will remain for as long as possible given security conditions.

The officials were not authorised to discuss diplomatic movements and spoke on condition of anonymity.

Meanwhile, wisps of smoke could be seen near the embassy’s roof as diplomats urgently destroyed sensitive documents, according to two American military officials who spoke on condition of anonymity because they were not authorised to discuss the situation.

Passengers walk to the departures terminal of Hamid Karzai International Airport in Kabul, Afghanistan
Passengers walk to the departures terminal of Hamid Karzai International Airport in Kabul (Rahmat Gul/AP)

The smoke grew heavier over time in the area, home to other nation’s embassies as well.

Nato, meanwhile, said it was “helping to maintain operations at Kabul airport to keep Afghanistan connected with the world”.

Low-cost carrier FlyDubai said it would temporarily suspend flights to Kabul. It turned around a flight to the capital on Sunday, as did Emirates.

Emirates said an “unforeseen temporary closure of the runway” stopped it from landing.

Earlier in the day, militants posted photos online showing them in the governor’s office in Jalalabad, the capital of Nangarhar province.

Abrarullah Murad, a lawmaker from the province told the Associated Press that the insurgents seized the city after elders negotiated the fall of the government there. Murad said there was no fighting as the city surrendered.

Taliban fighters sit on the back of a vehicle in the city of Herat, west of Kabul, Afghanistan
Taliban fighters sit on the back of a vehicle in the city of Herat (Hamed Sarfarazi/AP)

The militants also took Maidan Shar, the capital of Maidan Wardak, on Sunday, Afghan lawmaker Hamida Akbari and the Taliban said.

Another provincial capital in Khost also fell to the insurgents, said a provincial council member who spoke on condition of anonymity for fear of reprisals. Afghan officials said the capitals of Kapisa and Parwan provinces also fell.

The militants also took the land border at Torkham, the last not in their control, on Sunday. Pakistan’s Interior Minister Sheikh Rashid Ahmed told local broadcaster Geo TV that Pakistan halted cross-border traffic there after the militants seized it.

Later, Afghan forces at Bagram air base, home to a prison housing 5,000 inmates, surrendered to the Taliban, according to Bagram district chief Darwaish Raufi. The prison at the former US base held both Taliban and Islamic State group fighters.