The Taliban have released 235 villagers held since the fighters seized control of an area in northern Sar-e Pul province five days ago, Afghan provincial officials said on Wednesday.

Local authorities believe the capture of the area was jointly carried out by the Taliban and Islamic State of Iraq and the Levant (ISIL, also known as ISIS) fighters. If confirmed, this will mark the first time the two rival groups have joined forces in battle.

The information was gleaned after some of the freed villagers told local media that they saw both the Taliban's white banner and ISIL's black flag flying together during the attack.

The civilians were released after negotiations between the Taliban and tribal elders.

Speaking from Kabul, Al Jazeera's Jennifer Glasse said that the freed villagers were instructed by their hostage-takers not to say anything to the media because at least 18 people were still being held hostage.

"They say that two different groups had approached the village from two different sides, and that one group was far more brutal than the other, killing everything in its path and burning some 30 houses," Glasse said.

READ MORE: Officials - Taliban, ISIL coordinated Sar-e Pul attack

In Sar-e Pul, the fighters defeated Afghan local police forces after almost two days of intense fighting and took control of the area early on August 5, Zaib Amani, the spokesman for the provincial governor, said.

Most of the civilians are staying in local mosques or with relatives in the city and provincial officials are trying to provide food and other necessities for them before finding a long-term solution, he added.

Amani also said that since the fighters took control of the area, 52 civilians, including women and children, have been killed in the village of Mirza Olang in Sayad districts. The victims were mostly Shia Muslims and minority Hazaras.

Afghan President Ashraf Ghani condemned the killings in Mirza Olang.

"I will promise that our brave security forces will take revenge," Ghani said during a ceremony at the presidential palace, broadcast live on TV.

Provincial governor Zahir Wahdat said as many as 450 families had fled the fighting, which has underscored the lack of government control in many areas of Afghanistan and deepened public anger at the growing insecurity.

Sayed Ismail, a man who said he had been detained and then released by ISIL, told Reuters news agency he had lost three members of his family, including a son and grandson.

"Government officials put their hands on the holy Quran to provide security for us, but they have their security guards and armoured cars and do not think of their people," he said.

"We were with Daesh for four days," he said, using a common Arabic name for ISIL. "Some of our relatives were buried without shrouds and their dead bodies were spoiled in open weather. We are tired of our government."

Qari Yousuf Ahmadi, a Taliban spokesman, confirmed the fighters had seized the area but denied civilians were killed in Mirza Olang.

So far, ISIL has not commented on the attack or said whether it had joined forces with the rival Taliban.

There have been reports of battles in the past months between the Taliban and the ISIL affiliate in Afghanistan in several provinces. Afghanistan's ISIL affiliate is made up mostly of disenfranchised former Taliban members.

Two women shopping at market shot and killed

Meanwhile, gunmen opened fire on a group of four female employees at the Bagram airfield, the main US military base in the country, killing one and wounding a second woman, said Zaman Mamozai, the provincial police chief.

He said that two suspects were later arrested in connection with the shooting.

Abdul Shukor Qudosi, governor of northern Bagram district, told Anadolu Agency that a group of four women guards employed at the airbase were shopping at a nearby market at around noon time when they came under attack.

"Four women employees of a private security firm stationed at the outer first entry point of the base were shot at in the market," he said, adding one of the women died on the spot, while a second one succumbed to her wounds on the way to hospital.

There was no immediate claim of responsibility for the attack.