MIGUEL ALEMÁN, Mexico—Ciudad Mier, a picturesque colonial village on the Texas border, was a sleepy tourist attraction until February, when two rival drug cartels turned it into a slaughterhouse.

Caravans of armored SUVs crammed with gunmen firing automatic rifles prowled the streets. Parents pulled terrified children from schools. The town of 6,000 went dark every time the combatants shot out the transformers. In May, a man was hung alive from a tree in the central plaza and dismembered while town folk heard the screaming...