The Isis and Taliban terror groups have reportedly joined forces to carry out an attack in Afghanistan, killing dozens of civilians, according to officials.

In a rare case of cooperation, militants from both groups are believed to have united and killed more than 50 men, women and children in the Sayad district, in the northern Sar-e Pul province, on Saturday 5 August.

The attack took place when the militants managed to overrun the police following a 48-hour-long battle. The majority of the victims were Shia Muslims, some of whom were beheaded. Officials expect the death toll to rise.

"It was a joint operation by Daesh [Isis] and Taliban fighters. They had recruited forces from other provinces of the country and attacked Mirzawalang village," Zabihullah Amani, a spokesman for the provincial governor, told AFP. "The fighters overran the area and it led to the massacre of innocent and defenceless civilians."

It is believed the joint attack took place after members of both groups united under the command of Sher Mohammad Ghazanfar, a local Taliban commander who pledged allegiance to Isis.

Taliban spokesperson Zabihullah Mujahid, however, denied the allegations. He told AFP: "It was an independent operation by our mujahideen forces. There is no cooperation with the [Daesh] on the operation." He also denied that civilians were killed.

Saturday massacre was the latest of a series of attacks that have rocked Afghanistan in recent months. Attacks have been claimed by both the Taliban and Isis.

Is an alliance likely?

Afghan Herat city mosque attack
Relatives mourn outside at a hospital, after an overnight suicide attack at a mosque in Herat, Afghanistan. August 2, 2017. Reuters/Mohammad Shoib

The Taliban, a Sunni fundamentalist political movement, took control of Afghanistan in 1996, imposing a strict version of Islam and persecuting anyone who would not abide by their laws. Although Taliban rule ended following the US invasion in 2001, its insurgents still control some areas of the country.

Isis controls swathes of territories in Iraq and Syria and, through local alliances, in parts of Africa and Asia.

The two groups have competed for supremacy in Afghanistan since Isis established a foothold in the country in 2015.

In June, Isis reportedly seized from the Taliban a mountain redoubt, known as Tora Bora, in the Nangarhar Province, following week-long fighting. The Taliban, however, has denied the claims.

David Otto, a UK-based counterterrorism expert, believes that the claims by the officials, if substantiated, could signal a shift in the insurgencies in the country, where the two groups could ally to fight against their common enemy: The Kabul government. "It is also an indication that when jihadist groups face pressure , they are forced to collaborate with each other," he told IBTimes UK.

Isis is progressively losing territories in Iraq and Syria, where coalition forces have recaptured most territories in Mosul and Raqqa respectively, Isis strongholds in the Middle East.

"This is a worrying concern to not only the local government but regional and international coalitions against the 'war or terror'. It shows that these non-state groups continue to evolve into different forms as conditions on ground alter their status," Otto said.

"The more these jihadist groups collaborate, the more difficult it becomes to counter them, especially when the coalition is not united in their short and long term outcome. The thought of the Taliban and by default al-Qaeda and Isis sitting on the same table to plan and prepare against their perceived and real enemy is simply a disaster."

Kabul blast
Afghan security personnel inspect the site of a car bomb attack in the western part of Kabul, Afghanistan, on 24 July 2017 Reuters TV