Dambao - Witnesses say suspected militants lured the faithful to a mosque then gunned them down.
They say the gunmen killed at least seven people before being attacked by soldiers guarding Damboa village, 85 kilometers (50 miles) west of the Borno state capital of Maiduguri in northeast Nigeria.
Military spokesman Captain Aliyu Danja said troops killed 15 attackers.
Resident Kolomi Abba said the attack comes after he formed a group of civilian vigilantes to fight the extremists.
He said the gunmen came around 4 a.m. Saturday and forced the muezzin to chant the call to prayer that usually happens at 5 a.m. When villagers arrived, the extremists opened fire.
It is the latest in a string of attacks blamed on the Boko Haram group fighting to install an Islamic state.