Story highlights There were no U.S. casualties in the attack in Herat province

Militants drove a truck towards the U.S. consulate gate

The Taliban claimed responsibility for the attack

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.

U.S. Ambassador James B. Cunningham in a statement 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.