Afghan President Ashraf Ghani said Sunday after fleeing the country that the Taliban had won, as the militants entered Kabul -- nearly 20 years after they were ousted from power by a US-led invasion.

Ghani left as the insurgents closed in on the capital, before ultimately entering the city and taking over the presidential palace, sealing a nationwide military victory in just 10 days.

The Taliban have carried out a lightning sweep of the country, with government forces collapsing without the support of the US military, which is finalising its withdrawal in alignment with an August 31 deadline set by President Joe Biden.

Insurgent fighters are now camped just 50 kilometres away from the Afghan capital
Insurgent fighters are now camped just 50 kilometres away from the Afghan capital AFP / -

The insurgents' imminent takeover triggered fear and panic in Kabul among residents fearful of the group's hardline brand of Islam, which it imposed during its 1996-2001 rule.

"The Taliban have won with the judgement of their swords and guns, and are now responsible for the honour, property and self-preservation of their countrymen," Ghani said in a statement posted to Facebook, his first since fleeing.

"They are now facing a new historical test. Either they will preserve the name and honour of Afghanistan or they will give priority to other places and networks," he added, saying he left to prevent a "flood of bloodshed".

The scale and speed of the Taliban advance has shocked Afghans and the US-led alliance that poured billions into the country
The scale and speed of the Taliban advance has shocked Afghans and the US-led alliance that poured billions into the country AFP / -

Ghani did not say where he had travelled to, but leading Afghan media group Tolo news suggested he had gone to Tajikistan.

For Kabul residents and the tens of thousands who have sought refuge there in recent weeks, the overwhelming mood was one of confusion and fear of what lies ahead
For Kabul residents and the tens of thousands who have sought refuge there in recent weeks, the overwhelming mood was one of confusion and fear of what lies ahead AFP / WAKIL KOHSAR

After initially ordering fighters not to enter the capital, a Taliban spokesman confirmed the Islamist insurgents had entered several districts in Kabul to "ensure security."

Three senior Taliban sources also told AFP that their fighters had taken control of the presidential palace and were holding a meeting on security in the capital.

Fighters inside the palace said they had been "victorious," in footage aired on Al-Jazeera.

Taliban fighters drive an Afghan National Army (ANA) vehicle through a street in Kandahar
Taliban fighters drive an Afghan National Army (ANA) vehicle through a street in Kandahar AFP / -

"The former Afghan president has left the nation, leaving the people to this situation," Abdullah Abdullah, who heads the peace process, said in a video on his Facebook page.

Ghani's departure from office was one of the key demands of the Taliban in months of peace talks with the government, but he had stubbornly clung to power.

The insurgents said they want a "peaceful transfer" within the next few days.

Map of Afghanistan locating the cities that have fallen to the Taliban.
Map of Afghanistan locating the cities that have fallen to the Taliban. AFP / STAFF

UN Secretary General Antonio Guterres urged the Taliban and all parties to "exercise restraint" and said that the rights of women and girls, who suffered under the previous Taliban regime, be protected.

The UN also said the Security Council would meet over Afghanistan on Monday.

Taliban fighters are seen outside a police station in Herat, Afghanistan's third biggest city. Duration 00:31
Taliban fighters are seen outside a police station in Herat, Afghanistan's third biggest city. Duration 00:31 AFPTV

There are fears of a security vacuum in Kabul as thousands of police and other armed services members have abandoned their posts, uniforms, and even weapons.

The United States began moving its citizens and Afghan staff to Kabul airport, with the help of thousands of troops deployed to the capital to assist with the evacuation.

Taliban fighters drive a government vehicle through a conquered city
Taliban fighters drive a government vehicle through a conquered city AFP / -

A US defense official said several hundred embassy employees had already been evacuated from Afghanistan, and that the airport remained open to commercial flights.

The US embassy said there had been "reports of the airport taking fire" but those were not immediately confirmed.

NATO Secretary General Jens Stoltenberg said the Western alliance was working to keep the airport running "to facilitate and coordinate evacuations", as foreign nationals and Afghans converged on the facility to attempt to leave the country.

US Secretary of State Antony Blinken nevertheless dismissed comparisons with the chaotic American departure from Saigon in 1975.

"The fact of the matter is this: We went to Afghanistan 20 years ago with one mission in mind," he said Sunday.

"That was to deal with the people that attacked us on 9/11. That mission has been successful."

The scale and speed of the insurgents' advance have shocked Afghans and the US-led alliance that poured billions into the country over the past two decades.

President Joe Biden ordered the deployment of an additional 1,000 US troops to help secure the evacuation of embassy employees and thousands of Afghans who worked for American forces and now fear Taliban reprisals.

That brought the total expected in Kabul in the coming days to 6,000.

Biden's decision to stick to his withdrawal timetable has come under increased scrutiny given the collapse of the Afghan armed forces, but he insisted there was no choice and he would not "pass this war" onto another president.

Ghani's government was left completely isolated on Sunday after the insurgents overran the anti-Taliban northern stronghold of Mazar-i-Sharif and the eastern city of Jalalabad.

Like with most of the other captured cities, the seizure of power came after government forces surrendered or retreated.

Videos posted on pro-Taliban social media accounts showed the group's heavily armed fighters in cities across the country, waving white flags and greeting locals.

In Kabul, many resident were already resigned to the Taliban taking power.

"My only wish is that their return leads to peace. That is all we want," said Kabul shopkeeper Tariq Nezami.

For the tens of thousands who have sought refuge in Kabul in recent weeks, the overwhelming mood was one of apprehension and fear.

"I would rather return home, where I know it has stopped."