Nigeria's military on Sunday repelled a Boko Haram assault on the key northeastern city of Maiduguri, as violence raged across the region just two weeks before national elections.
The hours-long attack on the strategic capital of Borno state was the Islamists' second attempt to take Maiduguri in a week.
Separately, a suicide bomber killed seven people in Potiskum, the economic capital of neighbouring Yobe state.
With near-relentless violence plaguing much of the northeast, and Boko Haram still in control of large swathes of territory in the region, fears are mounting over the prospect of organising polls on February 14.
The opposition All Progressives Congress (APC), which claims to be gaining momentum in the campaign against President Goodluck Jonathan, has rejected a call by the national security advisor for the vote to be postponed.
But hundreds of thousands of voters in the northeast, an APC stronghold, could be disenfranchised by the unrest if the election goes ahead in two weeks.
'Massive' insurgent casualties
Heavily-armed gunmen attacked the southern edge of Maiduguri at roughly 3:00 am (0200 GMT), setting off explosives as they tried to enter the city, several residents said.
Repelled in the south by troops backed by vigilantes, they regrouped and tried to take the city from the east, where they again met stiff resistance.
As the gunbattles raged, "the whole city (was) in fear," said resident Adam Krenuwa, adding that people were afraid of the consequences should Boko Haram overrun Maiduguri, where the extremist group was founded more than a decade ago.
Defence spokesman Chris Olukolade said the assault was "contained" and that "the terrorists incurred massive casualties." "The situation is calm as mopping up operation in the affected area is ongoing," he wrote in a text message, a claim consistent with witness reports.
Despite waves of attacks in the city in recent months, Maiduguri has become a place of refuge for people forced to flee other areas in Borno that have been taken over by the Islamist rebels.
Campaign meeting attacked
In Potiskum, a bomber blew himself up shortly after midday outside the home of Sabo Garbu, who is running for a seat in the lower house of parliament on behalf of the ruling People's Democratic Party (PDP).
A bus stopped outside his home and dropped off the attacker before speeding away, multiple witnesses said.
Seven people died in the blast and seven others were injured, said a police officer at the scene who requested anonymity, in an account supported by three witnesses.
Garbu and those attending his campaign meeting reportedly escaped unhurt.
Boko Haram has carried out dozens of similar bombings throughout its six-year uprising, which has claimed more than 13,000 lives.
But it was not immediately clear why the Islamists would have specifically targeted Garbu and it was possible that another group with a separate political motive was responsible for the attack.
Polls in two weeks
Election officials have insisted the vote will go ahead on February 14, but conceded that voting will be impossible across much of the northeast.
Foreign observers have said that they will not even attempt to monitor polling in the region because of the unrest.
Jonathan, who is facing a stiff challenge from former military ruler Muhammadu Buhari, has repeatedly sought to assure Nigerians that Boko Haram could be contained.
But those promises have consistently proved hollow, with the violence having escalated each year under his watch and his management of the crisis being fiercely criticised, including during the presidential campaign.
Buhari, a former army general who briefly led the country as a military dictator in the mid-1980s, has told voters that he will be able to curb the bloodshed but has so far not released a specific plan to deal with Boko Haram that he would implement if elected.