The attack, the latest in a wave of assaults by extremist gunmen, was repulsed hours before President Muhammadu Buhari was sworn into office for a second term in power, AFP reported.
Soldiers intercepted a "huge number" of terrorists from Boko Haram on the outskirts of Maiduguri on Tuesday night, beginning a nightlong battle that continued until close to dawn on Wednesday.
"Our troops did an impressive job, and fought off the terrorists," said a military source, who asked to be named.
Troops fought all night, and "forced them to withdraw by dawn," the source said.
A member of a self-defense militia that fights alongside regular troops said Boko Haram terrorists were spotted as they moved toward the city in the dark.
"Luckily they were sighted by soldiers, who fought them all night long," the militia fighter said.
Residents of the city reported the sounds of a heavy battle.
"We kept hearing explosions and the sound of gunfire throughout the night," Maiduguri resident Nasiru Fannami said.
It was not clear if there were any casualties.
Boko Haram terrorists have launched several failed attempts to overrun Maiduguri.
Their decade-long campaign of violence has killed tens of thousands of people and displaced millions across the region.
The violence has spilled over into neighboring Niger, Chad and Cameroon, prompting a regional military coalition to battle the terror group.
Buhari, who was sworn in as president for a second four-year term later on Wednesday, has said defeating of Boko Haram – and ending a raft of other security threats – is a key part of his work.