Image copyright AFP Image caption Villagers gathered at the site of the attack to mourn the victims

Thirty people have been kidnapped and killed by militants linked to so-called Islamic State in Afghanistan's central Ghor province, officials say.

The civilians, along with two flocks of sheep, were taken as they collected firewood in the mountains.

An IS commander was killed by police trying to free them, and the militants killed the civilians in revenge, Ghor Governor Nasir Khazeh told the BBC.

IS is gaining support and challenging the Taliban in Afghanistan.

The killings occurred late on Tuesday north of Firoz Koh, the capital of Ghor province. The civilians killed included children, Mr Khazeh said.

Central Afghanistan has not been known as a centre of IS activity, which has so far mostly been concentrated in Nangarhar state in the east of the country.

Analysts say the IS militants in Ghor are former Taliban fighters. The Taliban and IS declared war on each other last year.

IS v the Taliban

Image copyright AP Image caption The Taliban and Islamic State declared war on each other in January 2015

The Taliban and IS have been locked in frequent battles in Afghanistan since January 2015.

The Taliban's dominance in a region home to numerous local and foreign militant groups is facing a serious challenge from IS.

There has also been evidence that IS is trying to recruit Taliban fighters, with several Taliban commanders declaring allegiance to IS.

Why Taliban special forces are fighting Islamic State

Afghanistan fighters 'linked to Islamic State in Syria'

Islamic State 'recruiting Afghan fighters'