KABUL (Reuters) - Afghan President Hamid Karzai said on Monday that a coordinated Taliban attack showed a “failure” by Afghan intelligence and especially by NATO, as heavy street fighting between insurgents and security forces came to an end after 18 hours.

Battles which broke out at midday on Sunday gripped the city’s central districts through the night, with large explosions and gunfire lighting up alleys and streets.

“The fact terrorists were able to enter Kabul and other provinces was an intelligence failure for us and especially for NATO,” Karzai’s office said in a statement, which also strongly condemned the attack.

Though the death toll was relatively low considering the scale of the assault, it highlighted the ability of militants to strike at high-profile targets in the heart of the city even after more than 10 years of war.

Karzai echoed his Western backers by praising Afghan security forces, saying they had proven their ability to defend their country - a task which will increasingly fall to them as foreign armies reduce their troop numbers in Afghanistan.

His office said 36 insurgents were killed in the attacks which paralyzed Kabul’s government district, and which targeted three other provinces in what the Taliban called the start of a spring offensive. One fighter was captured.

Eleven members of the Afghan security forces and four civilians were killed in the well-planned attacks in Kabul and the eastern Nangarhar, Logar and Paktia provinces, it said.

“In only a short time we managed to cut short their devilish plans,” said Defense Ministry Chief of Operations Afzal Aman. “They carried suicide vests, but managed to do nothing except be killed.”

The attacks were also another election-year setback in Afghanistan for U.S. President Barack Obama, who wants to present the campaign against the Taliban as a success before the departure of most foreign combat troops by the end of 2014.

Insurgents were killed attacking the Afghan parliament, and in a multi-storey building under construction that they had occupied to fire rocket-propelled grenades and rifles down on the heavily fortified diplomatic enclave.

More were killed in Kabul’s east, and while attacking a NATO base in the eastern city of Jalalabad.

Fighting in the capital only ended with special forces assaults which were mounted as dawn broke.

Assisting physically for the first time in the attack, NATO helicopters launched strafing attacks on gunmen in the building site, which overlooked the NATO headquarters and several embassies, including the British and German missions.

Elite Afghan soldiers scaled scaffolding to outflank the insurgents, who took up defensive positions on the upper floor of the half-built structure. Bullets ricocheted off walls, sending up puffs of brick dust.

“I could not sleep because of all this gunfire. It’s been the whole night,” said resident Hamdullah.

The assault, which began with attacks on embassies, a supermarket, a hotel and the parliament, was one of the most serious on the capital since U.S.-backed Afghan forces removed the Taliban from power in 2001.

Slideshow ( 11 images )

STRIKE ON THE DIPLOMATIC ZONE

The Taliban claimed responsibility, but some officials said the Haqqanis, a network of ethnic Pashtun tribal militants allied with the Taliban, who live along the Pakistan-Afghanistan border, were likely involved.

“My guess, based on previous experience here, is this is a set of Haqqani network operations out of North Waziristan and the Pakistani tribal areas,” American Ambassador Ryan Crocker told CNN.

North Waziristan, in Pakistan, is a notorious militant hub.

“Frankly I don’t think the Taliban is good enough,” Crocker said.

Slideshow ( 11 images )

Taliban spokesman Zabihullah Mujahid said the assaults in Kabul and three eastern provinces marked the beginning of a new warm-weather fighting season.

“These attacks are the beginning of the spring offensive and we had planned them for months,” Mujahid told Reuters.

He said the onslaught was revenge for a series of incidents involving U.S. troops in Afghanistan - including the burning of copies of the Koran at a NATO base, and the massacre of 17 civilians by a U.S. soldier - and vowed there would be more.

The Taliban said on Sunday the main targets were the German and British embassies and the headquarters of the NATO-led force. Several Afghan members of parliament joined security forces in repelling attackers from a roof near parliament.

The attacks came a month before a NATO summit at which the United States and its allies want to put the finishing touches to plans for the transition to Afghan security control, and days before a meeting of defense and foreign ministers in Brussels to prepare for the alliance summit in Chicago.

Western combat troops are due to leave Afghanistan by the end of 2014, under a plan to hand over responsibilities to Afghan forces.

But those forces are plagued by poor discipline, and they have apparently failed to learn lessons from a similar assault in Kabul last September, when insurgents took up a position in a tall building under construction to attack embassies and NATO offices below.

Hours before the Kabul attack, in neighboring Pakistan dozens of Islamist militants stormed a prison in the dead of night and freed nearly 400 inmates, including one on death row for trying to assassinate former President Pervez Musharraf.