The Taliban were in control of Afghanistan on Monday after President Ashraf Ghani fled the country and conceded the insurgents had won the 20-year war.

The astonishingly quick collapse of the government, with militants taking over the presidential palace on Sunday night, triggered fear and panic in the capital.

Thousands of people were on Monday trying to escape Kabul and the feared hardline brand of Islamic rule of the Taliban, with scenes of chaos as crowds gathered at the airport.

Taliban
Taliban fighters are seen in Afghanistan's Laghman province -- the militants are effectively in power after the country's president Ashraf Ghani fled Photo: AFP / -

Ghani fled on Sunday as the insurgents encircled Kabul, with the Taliban sealing a nationwide military victory that saw all cities fall to them in just 10 days.

"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.

In a video posted to social media, Taliban co-founder Abdul Ghani Baradar also announced his movement's victory.

US military helicopter
A US military helicopter is pictured flying above the US embassy in Kabul Photo: AFP / Wakil KOHSAR

"Now it's time to test and prove, now we have to show that we can serve our nation and ensure security and comfort of life," he said.

Government forces collapsed without the support of the US military, which invaded in 2001 after the September 11 attacks and toppled the Taliban for its support of Al Qaeda.

The United States ultimately failed to build a democratic government capable of withstanding the Taliban, despite spending billions of dollars and providing two decades of military support.

Taliban leaders
Profile of key Taliban leaders Photo: AFP / Gal ROMA

President Joe Biden was determined to withdraw all American troops by the end of this month, insisting there was no choice and he would not "pass this war" onto another president.

But the US administration was left shocked by the rapid collapse of the Afghan government.

Taliban
Taliban fighters in the eastern city of Jalalabad Photo: AFP / -

Despite insisting there would be no Saigon-style panicked evacuations from Kabul, American officials, their Afghan allies and other residents fearful of the Taliban were all trying to flee on Monday.

The United States had sent 6,000 troops to the airport to fly out embassy personnel as well as Afghans who assisted the United States as interpreters or in other support roles.

However the US government conceded it was not in control at the airport.

Taliban
Taliban fighters and local residents sit on a captured Afghan National Army humvee vehicle in Laghman province Photo: AFP / -

"We are completing a series of steps to secure the Hamid Karzai International Airport to enable the safe departure of US and allied personnel," the Pentagon and State Department said in a joint statement.

The United States then released a statement with more than 65 nations urging the Taliban to let Afghans leave the country, warning of accountability for any abuses.

"The United States joins the international community in affirming that Afghans and international citizens who wish to depart must be allowed to do so," Secretary of State Antony Blinken wrote on Twitter.

"Those in positions of power and authority across Afghanistan bear responsibility -- and accountability -- for the protection of human life."

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

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

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.

They then surrounded the capital.

Thousands of police and other government security forces suddenly abandoned their posts, uniforms, and even weapons on Sunday night.

After initially ordering fighters not to enter the capital, a Taliban spokesman confirmed they had entered Kabul on Sunday night to "ensure security".

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

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

"I am worried there will be a lot of fighting here," one doctor who arrived with his 35-strong family from Kunduz told AFP, asking not to be named.

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

Copyright AFP. All rights reserved.