The insurgents have so far not claimed responsibility for the attack in Kandahar province, which highlights long-simmering tensions between Afghan and foreign forces.
"Two Resolute Support (NATO) service members died this morning when two individuals wearing Afghan (security) uniforms opened fire... In southern Afghanistan," the military coalition said.
"Resolute Support members returned fire and killed the shooters."
The two soldiers were identified as Romanian, the defence ministry in Bucharest said, adding that the incident occurred during a training mission for Afghan police.
More From This Section
The attack comes after the insurgents last month announced the start of their annual spring offensive, vowing "large-scale attacks" across Afghanistan.
So-called "green-on-blue" attacks -- when Afghan soldiers or police turn their guns on international troops -- have been a major problem during NATO's long years fighting alongside Afghan forces.
In a similar attack in August last year, a man wearing an Afghan military uniform shot dead two American soldiers in the southern opium-rich province of Helmand.
Western officials say that most such attacks stem from personal grudges and cultural misunderstandings rather than insurgent plots.
The killings have bred fierce mistrust between local and foreign forces even as the rate of such incidents has dropped in recent years.
NATO troops have adopted special security measures in recent years to try to counter the threat.