NAW DEH, Afghanistan — Just before midterm exams in January, Mohammad Sadiq Halimi, the deputy education director for Farah Province in western Afghanistan, was given an ultimatum by local Taliban leaders.

Fire all male teachers at girls’ schools, Mr. Halimi said he was told. Replace them with women — men should not teach girls, the militants said.

The government did as it was told. “We didn’t want to give them an excuse” to shut down the schools by force, Mr. Halimi said.

But Farah’s schools were not spared. Last month, on two successive nights, armed men on motorcycles set fire to two girls’ schools just outside Farah city, the provincial capital. Both were badly damaged and the teaching materials inside were destroyed, ending classes indefinitely for nearly 1,700 girls. Graffiti on a nearby wall read, “Long live the Islamic Emirate” — the Taliban’s name for their movement.