The jihadists moved into Modu Ajiri and Bulama Kayiri villages in Borno state to take cattle and sheep but the villagers put up a fight to save their livestock.
"Eight people were killed in the fight and four others were injured," he said from the state capital Maiduguri, 90 kilometres away.
The militants opened fire on the villagers who were armed with machetes, bows and arrows, cudgels and swords, he said.
After the attack, the jihadists herded all the stolen livestock into the bush, he said.
He said residents of the two villages had fled for fear of renewed attack by the insurgents.
Mustapha said the bodies of the victims were recovered by soldiers and militia who took them to the nearby town of Nganzai, some 10 kilometres away.
Boko Haram has intensified attacks especially against military targets in recent months.
On Wednesday, scores of Islamists attacked a military base in Damasak in the far north of Borno state.
They were repelled with aerial support after an hours-long battle.
Boko Haram's nine-year insurgency has spilled over into neighbouring Chad, Niger and Cameroon, killing thousands of people and displacing over two million.
(This story has not been edited by Business Standard staff and is auto-generated from a syndicated feed.)