The incident occurred in southern Afghanistan.
The service members died after the pair opened fire on a compound.
Forces of the NATO-led Resolute Support mission returned fire and killed the shooters.
The killed NATO troops were Romanian. That country's president, Klaus Iohannis, issued a statement of condolence on his Facebook page. Another Romanian soldier was wounded.
CNN is trying to confirm reports that the Taliban claimed responsibility.
The attackers wore Afghan National Defense and Security Forces uniforms.
Afghan and NATO officials are conducting an investigation into the incident.
The NATO-led Resolute Support mission began January 1, 2015, as NATO made a transition from a combat role to a training and advisory mission.
The mission has reported a smattering of deaths and injuries to its members since it began.
In January, one U.S. service member died of wounds during operations in Marja in Helmand province, in the south, according to NATO. In December, six Resolute Support service members died in a car bombing in Bagram, the mission said.
In August, two Resolute Support servicemembers were killed when two people wearing ANDSF uniforms fired on their vehicle.That occurred at a compound in Helmand. The shooters were killed when Resolute Support service members returned fire.