Army spokesman Sani Usman said in a statement that troops killed a suspected female suicide bomber on Thursday when she tried to enter a military site in Yamtake in Borno state.
"The failed suicide bombing attack was followed up with futile probing attack by terrorists which was decisively dealt with by the troops," he said.
Usman said the troops killed all four attackers including two suicide bombers and recovered a cache of arms and ammunition.
"Unfortunately, we lost a soldier in the process," he said.
More From This Section
"Yesterday at about 10:00 PM suspected Boko Haram terrorists attacked a 119 Battalion Nigerian Army location at Mallam Fatori... The troops fought gallantly and repelled the attack, killing 14 Boko Haram terrorists," Usman said.
"Unfortunately, we lost an officer and four soldiers, while four other soldiers sustained various degrees of injuries during the encounter," he said.
Boko Haram, which seeks to impose a hardline Islamic legal system in Nigeria's mainly-Muslim north, has killed at least 20,000 people and forced more than 2.6 million to flee their homes since 2009.
Boko Haram has recently stepped up suicide attacks and bombings in and around Maiduguri, the centre of the violence.