Islamist insurgents have attacked the outskirts of northeast Nigeria's main city Maiduguri, engaging in a gun battle with soldiers that killed at least eight people.

Militant group Boko Haram has killed thousands since it launched its revolt in Maiduguri five years ago and wants the city to become the capital of a separate Islamist state.

"There is heavy gunfire going on. Everybody is panicking and trying to flee the area," said Idris Abubakar, a resident of Polo on the western outskirts of the city.

Growing violence by the insurgents is a major headache for President Goodluck Jonathan who faces elections on February 14 that analysts say are too close to call.

Capturing Maiduguri would be a huge victory for Boko Haram, which currently controls mostly rural areas along the Cameroon and Chad borders that together make up a territory the size of Belgium.

Resident Babagana Lawan said a grenade fell on his house, killing his brother and two factory workers living with him.

A security source confirmed the attack had occurred, but said troops had been mobilised to try to repel the insurgents.

Meanwhile, a suicide bomber has blown himself up outside the house of a legislator in the north-east Nigerian town of Potiskum, killing 10 people.

The bomber walked up to the house of Sabo Garbu, a member of the house of representatives in the federal government, before detonating the explosives.

Boko Haram has become the main security threat to the stability of Africa's biggest economy and top oil producer, and increasingly threatens its neighbours.