Boko Haram fighters attacked a military base and two surrounding villages near the flashpoint Nigerian city of Maiduguri overnight, killing at least 18 people and wounding 84, officials said on Monday.
It was one of the most brazen attacks in recent months and was a precursor to a planned strike on Maiduguri, the capital of Borno State and the birthplace of the Islamist group.
Boko Haram fighters attacked the base in the Cashew Plantation area on the outskirts of the city with suicide bombers, mortars and guns, leading to a prolonged battle, a senior military officer in Maiduguri said.
"Eighteen Boko Haram terrorists on foot attacked the military base while seven suicide bombers targeted residents of nearby Bale Shuwar and Alikaranti villages at 8:50 pm," said the officer who asked not to be identified.
"The terrorists fired mortars at troops," the officer said.
"So far we have recovered 18 dead bodies from the two villages," Benlo Dambatto, an official from the State Emergency Management Agency (SEMA) told AFP.
"The victims were killed while trying to escape the fight between the insurgents and the military," said Dambatto.
It was not immediately clear if the casualties involved only civilians or included the jihadists and soldiers as well.
The attackers were trying to infiltrate into the city, said Ba'Kura Abba Ali, a militia leader in the area helping soldiers in fighting Boko Haram.
The assailants climbed up a moat dug round the city to stave off Boko Haram suicide and gun attacks, and attacked troops, Ali said.
'Huge blasts, gunfire'
Maiduguri residents reported hearing at least five explosions and sounds of gunfire coming from the Cashew Plantation area.
"Huge blasts and sounds of gunshots were heard all over the city last night and they continued for more than an hour," said one resident, Ibrahim Gremah.
On Friday, four teenage girl suicide bombers killed two people in multiple attacks in Zawuya settlement on the outskirts of Maiduguri in the first assault since the government announced it was in ceasefire talks with Boko Haram.
The Islamic State-affiliated faction reportedly in talks with the government is led by Abu Mus'ab al-Barnawi and is known for attacks on military targets, while another faction led by Abubakar Shekau is notorious for suicide bombings killing civilians.
The attacks highlight the challenge the government faces in striking a ceasefire agreement with the factionalised Boko Haram.
Late last month, when more than 100 schoolgirls were returned to Dapchi after being kidnapped by the jihadist group, Nigerian President Muhammadu Buhari said his government was offering amnesty to "repentant" jihadists.
But senior security officials cautioned that reaching any agreement with the group will be difficult, as it is split into competing factions with different goals.
Boko Haram's nearly nine-year fight to establish an Islamic state in northeast Nigeria has claimed at least 20,000 lives and displaced more than two million people.