At least 44 worshippers in northeast Nigeria have been killed after gunmen opened fire on a mosque.

Suspected Islamist militants armed with automatic weapons fired on Muslims attending dawn prayers in the town of Konduga, Borno state, local officials said.

Some 26 people were injured and taken to a local hospital.

Four victims were said to be members of a civilian vigilante group who had rushed to the mosque to defend worshippers against the attack.

Usman Musa of the Civilian Joint Task Force said fellow vigilantes encountered "fierce resistance from heavily armed terrorists".

He said the attackers wore military camouflage uniforms used by the Nigerian army.

In an apparently simultaneous attack in nearby Ngom village, 12 people were killed.

Borno is one of the three northeastern states declared by Nigeria's President Goodluck Jonathan under a state of emergency as government troops fight to contain an insurgency led by Islamist group Boko Haram.

Boko Haram wants to bring down Jonathan's government and impose Islamic sharia law throughout the country. It has carried out numerous terrorist attacks in recent years, killing of more than 1,700 people since 2010.

The radical group's main targets are Christian churches, schools and government and military institutions. It is known to have attacked mosques whose clerics have spoken out against religious extremism.

The attack in Konduga was followed by a video of Boko Haram leader Abubakar Shekau bragging about recent attacks that was delivered to local media.

"We have killed countless soldiers and we are going to kill more," Shekau said. "[Our] strength and firepower has surpassed that of Nigeria. We can now comfortably confront the United States of America."

Nigeria, a nation of more than 160 million people, is divided almost equally between the predominantly Muslim north and the mainly Christian south.

Boko Haram mosque nigeria
A member of vigilante group Civilian Joint Task Force on patrol in Borno state where suspect Boko Haram militants attacked a mosque (Reuters)