Armed men have attacked a village in the northern Afghan province of Sar-e Pul, killing as many as 40 people, including women and children, officials have said.

Afghan President Ashraf Ghani on Sunday condemned the killings that he dubbed a "war crime".

"This barbaric act of them is deemed a direct violation of human rights and a war crime," Ghani said in a statement.

Mohammed Zaher Wahdat, the governor of Sar-e Pul, said that "as many as 30 to 40 innocent people ... were brutally shot and killed" in the province's predominately Shia village of Mirzawalang after Taliban fighters captured it on Saturday.

The governor told AFP news agency that several mosques were set ablaze and an unknown number of villagers were taken hostage following a 48-hour battle between the fighters and Afghan security forces.

At least 12 fighters and seven Afghan troops were killed in the fighting, he said.

Many details of the attack, including the identity of the fighters, were not immediately clear.

READ MORE: Father of robotics team member killed in Herat attack

The Taliban said it had captured Mirzawalang, but rejected reports of civilian casualties as "hollow propaganda by the enemy".

The fighting is still ongoing.

Earlier in the day, a spokesman for Wahdat told Reuters that the attackers included foreigners.

A senior government official in the capital, Kabul, told Reuters that security forces, including Afghan Air Force attack aircraft, were being sent to the scene.

Fighting has intensified this year across Afghanistan, with dozens of security incidents recorded every day.

In the first half of the year, 1,662 civilians were killed and 3,581 injured, according to the UN figures.

In a recent report, the Special Inspector General for Afghanistan Reconstruction (SIGAR), a US oversight body, said 60 percent of Afghanistan's districts are under government control, while the remaining 40 percent are held by the Taliban or other armed groups.

At least 2,531 Afghan troops were also killed between January and May, SIGAR said.

Thousands of US forces have been stationed in Afghanistan since 2001, when the US forces drove the Taliban from power. But the armed group has since regrouped and now poses a major security challenge for the Western-backed government in Kabul.