Most of the residents have left to avoid the possibility of another, and larger, intrusion by foreign militants.