Kabul: A Taliban suicide bomber rammed a car packed with explosives into a wall around the German consulate in the northern Afghan city of Mazar-i-Sharif late on Thursday, killing at least four civilians and wounding scores, officials said.
A Nato spokesman said the explosion had caused "massive damage" to the building, where around 30 people normally worked. Heavily armed attackers followed up the blast, battling with Afghan and German security forces late into the night.
The Taliban claimed responsibility for the attack, saying it was in retaliation for Nato air strikes against a village near the northern city of Kunduz last week in which more than 30 people were killed.
The Islamist movement's spokesman, Zabihullah Mujahid, said by telephone that heavily armed fighters, including suicide bombers, had been sent "with a mission to destroy the German consulate general and kill whoever they found there".
Noor Mohammad Faiz, the head doctor in Mazar-i-Sharif provincial hospital, said four dead bodies and 120 wounded had been brought to the hospital and that the numbers may rise.
The attack highlighted the security problems spreading across Afghanistan in recent months, with heavy fighting in areas from the volatile southern province of Helmand to Kunduz in the far north.
More than 30 people, many of them children, were killed last week when US aircraft carried out air strikes in support of Afghan and US special forces who came under attack during a raid against suspected Taliban militants threatening Kunduz.
Germany, which heads the Nato-led Resolute Support mission in northern Afghanistan, has about 850 soldiers at a base on the outskirts of Mazar-i-Sharif, with another 1,000 troops coming from 20 partner countries.
A foreign ministry spokesman in Berlin said the attack was suppressed in the early hours of Friday by Afghan and German security personnel, as well as Nato special forces.
"All German employees of the Consulate General are safe and uninjured," he said. It was not yet known how many Afghan civilians and security personnel were killed or wounded, the spokesman said.
The explosion occurred about an hour before midnight local time, a spokesman for the German military joint forces command in Potsdam said.
Witnesses reported sporadic gunfire from around the consulate and said the huge blast had shattered windows in a wide area around the compound.
"It was a prepared attack for which we made all arrangements," Mujahid said. "As per our plan, first a suicide bomber driving an explosives-laden vehicle rammed the main building of the consulate and that enabled other fighters to move in and kill all the foreigners there."
By the early hours of the morning, Afghan special forces were conducting search operations but were not encountering any more resistance, said Sayed Kamal Sadat, police chief of Balkh province.
Another provincial official, deputy police chief Abdul Razaq Qaderi, said at least one suspect had been arrested from the area of explosion.
The Nato spokesman said at least one car packed with explosives had been rammed into the high outer wall surrounding the consulate, but authorities were investigating if a second car had been involved.
The heavily protected consulate is located in a large building close to the Blue Mosque in the centre of Mazar-i-Sharif, where the Indian consulate was also attacked by militant gunmen earlier this year.
A crisis task force was set up in Berlin and Foreign Minister Frank-Walter Steinmeier was receiving continual updates, the German foreign ministry spokesman said.