The officer, who spoke on condition of anonymity, said the attackers, including seven suicide bombers, arrived on foot.
Boko Haram has killed some 20,000 people and displaced more than two million since it began a campaign of violence to create an Islamic state in the north of the country in 2009.
Another source said bodies were not immediately evacuated from the place of the attack, due to darkness.
A press statement signed by Colonel Onyema Nwachukwu, Deputy Director, Public Relations, Theatre Command, "Operation Lafiya Dole", said, "the four insurgents who had been routed out of the Sambisa Forest by troops in Operation Deep Punch II, were rummaging for food and logistics when they met their Waterloo".
When contacted by Vatican News, the Nigerian Catholic Secretariat condemned the ongoing terror by Boko Haram and called on the government to do more to protect innocent civilians.
AFP cited local emergency services as saying at least 18 people have been killed, while 84 were wounded in the attack in the villages of Bale Shuwa and Bale Kura.
"That's not correct. There was an attack which was repelled and some Boko Haram insurgents were killed by gallant soldiers".
But the process is troubled by factionalism within Boko Haram, say senior security officials.
Boko Haram fighters attacked a military base in the Cashew Plantation area at the entrance to the city with suicide bombers, mortars and guns, leading to a prolonged battle, a senior military officer in Maiduguri said.
The faction led by Abubakar Shekau is known for its use of suicide bombers.
"Talks have been ongoing between the government and the insurgents from the Al-Barnawi faction", said a source, speaking on condition of anonymity.
The latest attack in the troubled north-eastern state comes 48 hours after a similar attack on Friday killed one person and injured 13 persons.