Nigerian Islamist Boko Haram fighters have attacked the strategically important north-eastern city of Maiduguri, with dozens reported dead.
Earlier on Sunday they captured the north-eastern town of Monguno.
The BBC's Will Ross in Lagos says that with the insurgents gaining ground, Maiduguri is increasingly at risk.
US Secretary of State John Kerry meanwhile has arrived in Nigeria to call for peaceful elections next month which need to set "a new standard".
The vote looks set to be the closest since the end of military rule 15 years ago.
Our correspondent says that Mr Kerry is in Nigeria to show solidarity in the fight against Boko Haram, which has increased its attacks in recent days.
The BBC's Will Ross in Nigeria's commercial capital Lagos:
People in Maiduguri woke up to the sound of explosions and heavy gunfire as Boko Haram launched a pre-dawn attack on this strategic city.
Ground troops, air strikes and local vigilantes managed to stop the jihadists from penetrating the city. Much of the fighting was around a barracks.
In a separate attack the town of Monguno was captured - the latest to be seized by the group.
With the insurgents gaining more and more territory Maiduguri is increasingly vulnerable. It is home to tens of thousands of people who have fled their homes because of the conflict.
Fierce fighting has been reported on the outskirts of Maiduguri. A curfew remains in place and dozens of militants and soldiers are reported to have been killed.
Human rights group Amnesty International has warned that hundreds of thousands of civilians are now "at grave risk''.
Militants also attacked Monguno, 140km (86 miles) north of Maiduguri. The army there was reported to have been overwhelmed, with houses set on fire.
A journalist in Maiduguri told the BBC that fleeing soldiers from Monguno were now arriving at the barracks in in Maiduguri.
Boko Haram, which means "Western education is forbidden" in the Hausa language, launched guerrilla operations in 2009 to create an Islamic state.
Thousands of people have been killed throughout the insurgency, mostly in north-eastern Nigeria.
In his Lagos talks, Mr Kerry urged President Goodluck Jonathan and the main opposition's presidential candidate, former military ruler Muhammadu Buhari, not to condone violence during what is expected to be a tense election campaign,
"We are prepared to do more [to counter the Boko Haram threat] but our ability to do more will depend to some degree on the full measure of credibility, accountability, transparency and peacefulness of this election," Mr Kerry said.
Boko Haram at a glance
- Founded in 2002, initially focused on opposing Western-style education - Boko Haram means "Western education is forbidden" in the Hausa language
- Launched military operations in 2009 to create Islamic state
- Thousands killed, mostly in north-eastern Nigeria - has also attacked police and UN headquarters in capital, Abuja
- Has abducted hundreds, including at least 200 schoolgirls
- Controls several north-eastern towns
- Has launched attacks on Cameroon
Maiduguri would be a major prize for Boko Haram, which last tried to take the city in December 2013.
President Jonathan visited the city on Saturday as part of his election campaign for polls in February.
It was his second visit in two weeks.
On his visit on 16 January, he told some of the 5,000 refugees who had fled recent Boko Haram violence that they would soon be able to go back to their houses and that territory lost to the militants would soon be recaptured.
Are you in Maiduguri? Have you been affected by recent events? You can email email@example.com with your experiences. Please include a telephone number if you are willing to be contacted by a BBC journalist.