The attack in Herat, claimed by the Taliban, once again underscored a worrying security picture as Afghanistan prepares to take over from foreign combat after 12 years of war and stage crucial presidential elections next year.
A spokesman for the US embassy in the Afghan capital Kabul said all US personnel in the consulate in Herat were safe and had been accounted for.
He described the incident as a "complex" attack that included a car bomb.
Herat police chief General Rahmatullah Safi said a police officer and a translator had been killed and two Afghan staff working in the consulate had been wounded.
Abdul Raoof Ahmadi, a spokesman for the main hospital in Herat, later said 17 people had also been wounded. Mr Safi said Afghans and Americans had been trapped inside the consulate while fighting raged outside.
He added: "Taliban insurgents are in one compound fighting with Afghan guards and Americans are in another compound safe."
Taliban spokesman Qari Yusuf Ahmadi, who claimed responsibility for the attack, said: "Our aim for this attack is to show the Americans they are not safe anywhere in this country."
Exactly two years ago, insurgents staged a daring attack on the main US embassy and NATO headquarters in the heart of Kabul, killing at least nine people. The latest attack came two days after 9/11 commemorations.