Defence spokesman Chris Olukolade said troops repelled an ambush by Boko Haram militants on Wednesday in Mafa, Borno state, epicentre of the uprising which has killed 500 people this year alone.
"Twenty insurgents died in the encounter," he said in a statement.
There was no independent confirmation of the death toll. Communication with the region has been difficult after the military switched off mobile phone networks to prevent militants from planning attacks.
Witnesses and an area senator claimed the soldiers deployed in the town fled when the insurgents attacked, a claim fiercely denied by the military.
Olukolade today denounced such "inflammatory pronouncements by some highly placed persons in government" (and) "commentators in and outside the country who have consistently given false and misleading remarks to describe the disposition of troops".
There have been repeated reports of Nigerian troops fleeing when confronted by Boko Haram but Olukolade insisted "the Nigerian military cannot by any standard be overwhelmed by the insurgents".
Meanwhile, in the wake of a spate of gruesome massacres of students in the northeast, the education ministry said it had shut five government colleges (secondary schools) in "high security risk areas".
Students of the schools in the states of Adamawa, Borno and Yobe would be absorbed in other government colleges, the ministry statement said.
Last week, 43 students were shot and hacked to death when suspected Boko Haram gunmen stormed Federal Government College in Buni Yadi, Yobe state.
