Less than three weeks ago, an award-winning photographer for The Associated Press, Anja Niedringhaus, a German citizen, was killed by a police officer at a checkpoint in eastern Afghanistan. Her colleague Kathy Gannon, a Canadian reporter who had covered Afghanistan and Pakistan for The Associated Press for decades, was also wounded in the attack. A month before that, a Swedish journalist was shot and killed in a heavily guarded area of Kabul.

Image Dr. Jerry Umanos, a pediatrician from Chicago, was killed. Credit... Bernardo Barrios/Lawndale Christian Health Center, via Associated Press

The attacks are reminiscent of those by Afghan security forces against their Western allies that became a crisis two years ago. The violence, also known as insider attacks, threatened the military training mission at the heart of the American troop withdrawal scheduled for this year.

But as international coalition soldiers have increasingly stuck to their bases, and as new strategies have been put in place to safeguard against insider attacks, such episodes have seemed to subside. Instead, foreign workers in Afghanistan have been singled out, although the number of Western civilians targeted is still small compared with the number of military deaths — and both together are greatly outstripped by Afghan civilian casualties in the war.

Beyond the recent killings of journalists, a concerted effort by the Taliban to target locations that are popular with expatriates was evident before the presidential voting on April 5. An assault in January on a restaurant in central Kabul, the Taverna du Liban, left 21 people dead, most of them foreigners, and shootings at the luxury Serena Hotel last month killed nine. Such events have put the thousands of foreigners living in Kabul on high alert.

The unpredictable nature of the violence has prompted some embassies to redouble their security efforts, and has led those living outside secure areas to limit their exposure.

Friends and colleagues of Dr. Umanos said that he was keenly aware of the risks but was drawn to working with Afghans and helping to teach a new generation of doctors here.

“He was a very good teacher and clinician,” Robert F. Werner, who for a time lived in the same house as Dr. Umanos in Afghanistan, said Thursday in a telephone interview. “And he also had a great sense of humor, so culturally, he just did well. The doctors loved working with him.”