The killings took place during dawn prayers on Sunday morning, although news only emerged on Monday.
The attack occurred in the town of Konduga, 35km (22 miles) from the state capital Maiduguri.
The gunmen are suspected to be from the Islamist group Boko Haram, which has killed thousands in northern Nigeria since 2009.
Nigeria’s Daily Post reported that a further 26 people were being treated for injuries in hospital in Maiduguri.
A member of a civilian vigilante group told the Associated Press that four of their number were killed when they responded to calls for help.
Twelve further civilians were killed at Ngom village, closer to Maiduguri, reports say.
Nigeria’s President Goodluck Jonathan declared a state of emergency in three north-eastern states in May as his troops carry out an offensive against the Islamist militants.
Boko Haram wants to overthrow the Nigerian government and create an Islamic state in the north.
The BBC’s Will Ross, in Lagos, says that while the group has frequently attacked churches, it has also occasionally targeted mosques.
News of the attacks came as a video emerged of the group’s leader, Abubakar Shekau, claiming responsibility for recent attacks including some that targeted the police and the military.