An assault by Taliban insurgents on the heart of Kabul's diplomatic and military enclave ended this morning after 20 hours when security forces killed the last of six attackers, an Afghan government spokesman said.
It was the longest and most audacious militant attack on the Afghan capital in the decade since the Taliban were ousted from power and a stark reminder of the insurgents' strength and reach as Western forces start to return home.
At least 11 civilians were killed, more than half of them children, said General John R. Allen, the commander of Nato and US forces in Afghanistan. Five policemen also died.
He dismissed the raid as a military failure, but conceded that the hours of explosions and fierce gun battles, which angered and frightened Kabul residents and grabbed headlines around the world, had been a propaganda victory for the Taliban.
"I'll grant that they did get an IO (Information Operations) win," he told a group of journalists, using a military term for perceptions and public relations.
The insurgents had holed up in a multi-storey building still under construction and launched their attack early on Tuesday afternoon, firing rockets towards the US and other embassies and the headquarters of Nato-led foreign forces.
Three suicide bombers also targeted police buildings in other parts of the city, but the embassy district assault was the most spectacular.
Afghan security forces backed by Nato and Afghan attack helicopters fought floor-by-floor in the 13-storey building, which the insurgents appeared to have booby trapped. One or two fighters held out overnight.
"The operation has just ended and six terrorists were killed by police," Interior Ministry spokesman Sediq Sediqqi said on Twitter around 20 hours after the first explosions.
The six insurgents were armed with rocket-propelled grenade launchers, AK-47 assault rifles and suicide bomb vests, a Taliban spokesman said, but the amount of time they held out prompted speculation they had hidden weapons and ammunition in the building before the attack.
"There was almost certainly either a breakdown in security among the Afghans with responsibility for Kabul or an intelligence failure," said Andrew Exum, fellow at the Center for a New American Security.
Explosions were interspersed with gunfire all afternoon on Tuesday and several rockets landed in the upmarket Wazir Akbar Khan district, near the British and other embassies. One hit a school bus but it appeared to have been empty at the time.
Gunfire continued throughout the night, with residents of soviet apartment blocks near the insurgent hold-out staying indoors with their lights off, as children cried and helicopters flew low overhead.
"It would go silent for 30 to 35 minutes and then there were explosions and the sound of heavy machine guns," one witness said.
Embassies and restaurants frequented by foreigners were on lock-down all evening. The US and British embassies and the Nato-led coalition said all their employees were safe.
Violence is at its worst since US-backed Afghan forces toppled the Taliban government in late 2001, with high levels of foreign troop deaths and record civilian casualties.
The assault was the second big attack in the city in less than a month after suicide bombers targeted the British Council headquarters in mid-August, killing nine people.
In late June, insurgents launched an assault on a hotel in the capital frequented by Westerners, killing at least 10.
A US Senate panel has approved a $1.6 billion cut in projected US funding for Afghan security forces, part of a significant reduction in outlays for training and equipping Afghan army and police expected in the coming years.