Violence broke out on the outskirts of Maiduguri on Thursday night, with indications the militants were trying to reach the city’s Giwa Barracks, where suspected militants are held.
The attack — and an announcement that 22 soldiers from a regional force have been killed in fighting this month — again underlined the threat posed by the insurgents.
Nigeria has repeatedly maintained the Islamic State group affiliate is a spent force and on the verge of defeat.
In Maiduguri, Bashir Garga, from the National Emergency Management Agency, said: “There were innocent citizens, four of them, who died. Very few people were injured and none of them seriously.”
Five suicide bombers also died trying to detonate their explosives, he added.
The Borno state police gave a lower death toll of two, including a member of the civilian militia assisting the military with security against Boko Haram.
“The victims and corpses have been evacuated to the state specialist hospital in Maiduguri,” said police chief Damian Chukwu.
“Normalcy has been restored in the area.”
Thursday’s attack, which was repelled with the arrival of troop reinforcements and air support, was a rare urban incursion by Boko Haram.
Nigeria has been fighting Boko Haram in northern Borno around the shores of Lake Chad, which forms the border with Cameroon, Chad and Niger.
Troops from all four countries, and Nigeria’s western neighbour Benin, have combined in a regional force to combat the cross-border threat from the group.
Colonel Timothy Antigha, spokesman for the N’Djamena-based Multi-National Joint Task Force (MNJTF), said operations this month had made “substantial operational dividends”.
But 22 soldiers have been killed and 75 others wounded since April 5.
The nationalities of the dead were not disclosed. Force commander Major General Lucky Irabor attributed the high casualty rate to “indirect fire and vehicle-borne improvised explosive device attacks by terrorists”, Antigha added.
In Maiduguri, people fled the Jiddari Polo area, which has been repeatedly hit in recent years, as the insurgents fired automatic weapons and rocket-propelled grenades at troops.
The police said the attack was repelled “after a fierce gun battle” and firing of tear gas. Two officers were injured while seven others were also wounded, he added. Intelligence reports seen by AFP yesterday suggested more than 100 insurgents may have been involved in the attack.
Boko Haram fighters were pushed back to the Alidawari area on the outskirts of Maiduguri. Air strikes killed an unspecified number of militants as they fled, it added.
At least one member of the security forces was killed when a suicide bomber detonated his explosives near a military vehicle, the report added.
Search and clearance operations resumed at first light, when civilians who had escaped the attack began to return to their homes, it said.