Two NATO soldiers were shot and killed by an Afghan security official inside the interior ministry in Kabul Saturday afternoon, according to western officials.

The deaths prompted Marine Gen. John R. Allen, the top U.S. commander in Afghanistan, to recall all NATO personnel working in Afghan ministries in the Kabul area.

The step was taken “for obvious force protection reasons,” Allen said in a statement that capped a week marked by escalating distrust between NATO and Afghan forces. “We are investigating the crime and will pursue all leads to find the person responsible for this attack. The perpetrator of this attack is a coward whose actions will not go unanswered.”

Fratricide has been a growing problem between Afghan soldiers and their foreign counterparts here. In the past, Western military advisers have been advised to operate cautiously after such attacks. But this incident marks the first time a commander has publicly withdrawn his personnel from their posts for fear of attacks by men in Afghan uniforms.

“This afternoon, two of our international counterparts were killed inside the compound of the ministry. An investigation into the incident has already begun,” said interior ministry spokesperson Siddiq Siddiqi in a statement. The NATO-led International Security Assistance Force also confirmed the deaths of “two service members” in a statement.

Their bodies were discovered by another western official on the ground of a command center meeting room, at the heart of the fortified compound, according to Siddiqi, who said the specifics of the killings are still unclear.

The Taliban promptly claimed responsibility for the attack, saying the shooter was an insurgent infiltrator in the Afghans’ security forces.

At least three people were killed and dozens wounded on Saturday when protests turned violent in Kunduz, a province in northern Afghanistan. One crowd tried to storm the United Nations compound, but were resisted by armed guards.

“Although caused by legitimate defense, the United Nations also regrets the casualties among the demonstrators and expresses condolences to the families of those who lost their lives,” said the United Nations Assitance Mission in a written statement.

Four NATO service members have been killed in the last week, since the U.S. military burned a pile of Korans at a military base here, inciting five days of violent protests across Afghanistan. In the wake of that incident, the Taliban issued a statement asking Afghan soldiers and police to target their western counterparts.

Western military advisers were warned of an escalated risk of fratricide this week, and told to stay out of Afghan ministries unless their activities were “mission critical.” Even then, they were told to walk in groups of two more, and civilian advisers were asked to remain with an armed guard or soldier at all times.

Afghans have also been killed in protests. At least nine Afghans died Friday during demonstrations.

Six protesters and a police officer were killed in the western province of Herat when demonstrators tried to storm the U.S. Consulate, local officials said. At least one protester also was killed in Kabul as hundreds marched toward the presidential palace Friday afternoon, according to police, and another was killed in Baghlan province, north of the capital. At each demonstration, men shouted “Death to America” and demanded retribution.

The protests began outside Bagram air base after the apparently mistaken incineration of Muslim holy books on Monday was discovered. They have rattled the already fragile alliance between U.S.-led NATO forces here and the people and government of Afghanistan. More than 20 people have been killed since the protests began.

More than a dozen protesters were injured by police in the eastern province of Khost on Friday, government spokesman Mubarez Zadran said, as ­hundreds of people took to the streets after noon prayers, a focal point of the Muslim week and a common stepping-off point for demonstrations.

“They took advantage of the situation and burned private cars and shops,” Zadran said, adding that the majority of protesters were young men and teenage boys.

Hundreds more gathered in Jalalabad and Laghman, both in eastern Afghanistan. The protests turned briefly violent but faded by sunset.

Marine Gen. John R. Allen, the top U.S. commander in Afghanistan, said in a statement that the investigation into the Koran burning is ongoing. “Working together with the Afghan leadership is the only way for us to correct this major error and ensure that it never happens again,” he said.

Allen has apologized profusely for the incident, which some officials said involved Korans confiscated from a prison near the Bagram base because they were suspected of being used to pass inflammatory messages. The books were accidentally mixed with other materials destined for the incinerator, officials said.

President Obama apologized directly to Afghan President Hamid Karzai, and the U.S. military has pledged new training to avoid similar mistakes in the future. But the outreach has done little to quell the anger surging through Afghanistan and other parts of the world over an act that most Muslims would consider a desecration.

In Afghanistan on Thursday, interviews with several Afghan police officers indicated a deep level of sympathy for the protesters, and a shared sense of outrage among the demonstrators and those charged with keeping the peace.

“Afghans and the world’s Muslims should rise against the foreigners. We have no patience left,” said an Afghan police officer at a checkpoint in central Kabul. He looked at his colleague, who stood next to him, nodding. “We both will attack the foreign military people.”