A brazen Taliban assault on the Afghan capital was quelled on Wednesday after raging for 19 hours in a hail of rockets, grenades and suicide blasts that left 14 dead and six foreign troops wounded.
Afghan and foreign troops battled insurgents who targeted the US embassy and NATO headquarters, sowing fear and confusion and raising fresh questions over the Kabul government's ability to secure the country even after a 10-year war.
The standoff ended when troops finally killed the two last insurgents who had held out overnight in a high-rise building under construction just a few hundred metres from the heavily guarded US embassy.
"The last attackers are dead and the fighting all over. There were six terrorists in the building and all are dead," interior ministry spokesman Siddiq Siddiqui told AFP.
Afghan forces at the scene fired guns in jubilation from the top of the building after quelling the assault, kicking and stoning the corpses of attackers left behind, an AFP photographer at the scene said.
The Taliban claimed responsibility for the attack.
By holding part of the city hostage over two days in their longest assault on the capital yet -- the latest in a string of attacks on Western targets in recent months -- the insurgents demonstrated their increasing confidence.
The raid was another sign that security has deteriorated sharply in Kabul, which was hit with a suicide bombing on the British Council cultural body last month and the storming of the luxury Intercontinental Hotel in June.
But the US ambassador to Kabul, Ryan Crocker, played it down, even though around six rocket-propelled grenades (RPGs) landed in his embassy compound.
"This really is not a very big deal -- a hard day for the embassy and my staff," he said in a pooled media interview.
"Half a dozen RPG rounds from 800 metres away, that isn't Tet (a key offensive in the Vietnam War), that's harassment."
Crocker blamed the attack on the Haqqani network, a group allied with the Taliban seen as the insurgency's driving force along Afghanistan's porous border with Pakistan.
The insurgents, armed with suicide vests and rocket-propelled grenades, unleashed wave after wave of heavy explosions and gunfire after the attack started at around 1:30pm (0900 GMT) Tuesday.
Witnesses told of their terror as events unfolded.
"I was sitting in my shop when suddenly I heard an explosion and then another one. Then there was gunfire," said Abdulbaqi, a local shopkeeper. "People on the streets started running."
Kabul police chief Mohammad Ayoub Salangi told AFP that the six attackers inside the building, plus three others behind smaller suicide bombs elsewhere in the city Tuesday, had dressed in burkas to avoid searches at checkpoints.
He also claimed that data from their mobile phones showed they had been in touch with contacts in Pakistan, where militants are known to have hideouts, during the attacks.
The standoff ended after helicopters from the NATO-led International Security Assistance Force (ISAF) were sent in to assist Afghan forces, but it was not clear exactly how the last insurgents were killed.
A Taliban spokesman claimed responsibility for the attack by text message, saying that the targets were ISAF headquarters, the US embassy and Afghanistan's intelligence agency, the National Directorate of Security (NDS) and other "sensitive government places".
ISAF spokesman Lieutenant Colonel Jimmie Cummings said 11 Afghan civilians including three children were killed in the fighting.
Siddiqui said that three police officers had also been killed. Some 28 people are believed to have been injured, most of them civilians.
Cummings said that six foreign soldiers were also injured in the attacks -- three US troops who were defending ISAF's base from attacks and the others in the operation to clear the construction site of insurgents.
Afghanistan's spy agency NDS issued a statement urging Afghans to be extra-vigilant against the insurgent threat and report suspicious movements "out of a sense of national responsibility and moral duty".
The brazen raid came two months after NATO began a security handover to Afghan forces which will see a staged withdrawal of US-led combat troops due to finish in 2014.
Afghan forces have been in charge of security in Kabul since 2008 but frequently call on foreign troops for support in the event of major attacks.
At the US embassy, four Afghans were injured -- three applying for visas and one local security guard -- but no American members of staff.
The giant, high security US embassy compound borders the ISAF compound where thousands of foreign troops live and work.