An Afghan policeman killed two soldiers from the NATO-led force in southern Afghanistan on Saturday before he was himself shot dead, security and coalition officials said.
The incident brought to 47 the number of foreign military personnel killed in insider attacks this year.
The gunman was returning from a security operation in Helmand with coalition soldiers when he turned his gun on them, a security source told Reuters. He killed two soldiers and wounded three others.
A soldier returned fire, killing the attacker, a statement from the International Security Assistance Force (ISAF) said.
It was not immediately clear from which country the dead soldiers were.
The gunman was believed to be a member of the 16,000-strong Afghan Local Police, a U.S.-trained militia separate from the police. Training of new recruits was suspended earlier this month following a rise in insider attacks.