KABUL, Afghanistan — An Afghan police officer fired on American Special Operations troops and Afghan forces Monday morning, killing two coalition soldiers in the second insider attack in three days, Afghan officials said.

The shooting, at a joint military base in Wardak Province, happened shortly after a security meeting between the police and American and Afghan forces, the officials said. The gunman, who fired from a truck-mounted machine gun, was killed, said Gen. Mohammad Zahir Azimi, the Defense Ministry spokesman.

Afghan officials also said that three Afghan police officers died in the firefight, and that the district police chief was seriously wounded. The death toll for other Afghan security forces, including the commandos who shared the base with the Special Operations soldiers, was unclear. It was also not clear whether the attacker was a Taliban infiltrator.

The violence in Wardak Province, a Taliban stronghold southwest of Kabul that is often used as a staging ground for attacks on the capital, comes at a sensitive time for both the Americans and the Afghans.