KABUL, Afghanistan — In recent months, an increasing number of graphic images of atrocities in the Afghan war have circulated on social media — raising alarm that hatred sown deep into local communities would be difficult to resolve even if a peace agreement can be reached with the Taliban.

In one video, disheveled Taliban fighters line up a local judge in front of their guns as they repeat a question: who is rightful, the insurgents or the government? As the judge pleads “I serve the people,” the fighters open fire. The man collapses, and they fire more.

In a second video, Afghan Army soldiers have tied a couple of Taliban fighters to the hood of a military vehicle, driving them back and forth in a desert as they take turns beating them bloody. The Taliban wail as the soldiers curse at them and their families. One soldier repeatedly slashes a fighter with a knife.

“Slaves of Pakistan that fell to our hands,” the soldier filming the torture wrote on his Facebook account, referring to the neighboring country’s support for the Afghan insurgency. “Dear friends, please share.”