KABUL, Afghanistan — The sermon at the mosque in Kabul’s diplomatic quarter on Friday sounded a familiar but disquieting theme.

“You have disrespected the feelings of 1.8 billion Muslims and all that they hold sacred,” the imam, Muhammed Ayaz Niazi, bellowed, addressing the American forces in Afghanistan. “Those who have committed this grave crime are trying to test our people, to see if they are dead or alive. We promise to defend our values, defend our religion, defend our soil.”

Most of the Western missions are a stone’s throw from the mosque and, even if they didn’t understand the local language, their staffs could hear the anger.

Once again, the American military had stumbled into insulting the religion of the people they are here to help defend, inadvertently stoking anti-American anger and violence.