- The attack took place at an Afghan security forces compound in Helmand province
- The identities of the two service members who were killed haven't been disclosed
NATO service members fired back, killing the attackers, the organization's Resolute Support Mission in Afghanistan said in a statement.
It didn't disclose the identities of the service members who were killed, saying that would be left to the relevant national authorities.
Afghan and NATO officials are still looking into the circumstances of the firefight, which took place early Wednesday at an Afghan security forces compound in the southern province of Helmand, the Resolute Support statement said.
It wasn't immediately clear if the attackers were members of the Afghan security forces or had obtained the uniforms by other means.
The Resolute Support Mission, which focuses on training and support of Afghan forces, replaced NATO's formal combat mission at the end of last year.
As of the end of May, it consisted of more than 13,000 troops from 40 different nations. The United States is the largest single contributor, with more than 6,000 service members.
Attacks against NATO's presence in the country are frequent.
Three American contractors with the mission were among at least a dozen people killed in a suicide bombing of a convoy
in Kabul, the capital, on Saturday.
Earlier this month, an attack on a NATO coalition base
in Kabul killed at least one American, a defense official told CNN.