Soldiers openened fire on a woman, who was wearing a hijab after she refused to be searched as she approached the barracks in Bolari, and the shots detonated the explosives belt she was wearing and she died instantly.
According to an eyewitness, the Nigerian woman suicide bomber was killed as she tried to enter barracks in Bolari Gombe state.
"The woman refused to stop and continued to advance towards the military guards at the gates despite repeated orders from them to stop at a distance," said Shuaibu Nasir, who lives near the gates of the barracks.
"The soldiers opened fire on the woman who quickened her pace towards them and as they fired shots at her she exploded with a loud sound that shook our buildings," Nasir said.
The blast prompted policemen to fire warning shots in the air, causing panic among residents, Nasir said.
Another resident, Ahmed Baballe,said the would-be bomber was "blown to pieces" by the impact of the explosion.
"The soldiers didn't take chances with the woman and opened fire when she showed no sign of stopping to be searched," Baballe said.
Northeast Nigeria has been continually rocked by attacks mounted by Boko Haram extremists.
Experts have cast doubt on Nigeria's ability to hold planned national elections in February, because of the rising unrest in parts of the northeast.