Kabul, Afghanistan (CNN) -- A huge explosion rocked the area near the U.S. consulate in Afghanistan's Herat province early Friday during a heavy gunfight between militants and security forces, officials said.
The attack occurred just before 6 a.m. local time when attackers sped towards the front gate of the consulate, said Marie Harf, a deputy State Department spokeswoman.
The attackers fired assault rifles starting a gun battle with Afghan security forces. During the battle, a truck exploded, Harf said, causing major damage to the front gate of the consulate.
American consulate personnel took shelter in safe havens while U.S. security forces responded to the attack, Harf said. There were no U.S. casualties.
Seven attackers traveling in two vehicles took part in the assault and all of them were killed, said Mohammad Ayoub Salangi, deputy Afghan Interior Minister.
Three people, two local police officers and a local security guard, were killed, police and hospital officials said. Twenty others were injured.
The Taliban claimed responsibility for the attack in an e-mail to CNN.
According to the SITE intelligence group, the Taliban said it killed and wounded dozens of International Security Assistance Force and Afghan soldiers. It said nine Taliban fighters died.
Another communique said the Taliban was behind a suicide bombing that killed dozens of Afghans in Paktika, SITE reported.
U.S. Ambassador James B. Cunningham condemned the attack and lamented the Afghan citizens who lost their lives.
"Many Afghan civilians were killed in the attack, along with others who work for the Consulate as contractors. We are deeply saddened by this senseless loss of life," he said in a statement.