The insurgents opened fire on a military vehicle convoy late Monday in Hambagda village outside the town of Gwoza near the border with Cameroon, they said.
"A convoy of soldiers and vigilantes was ambushed by Boko Haram terrorists in Hambagda village in which we lost three soldiers," said a military officer in Maiduguri.
Two "Boko Haram terrorists" were killed" in a shootout, while the rest fled, said the officer, who asked not to be identified as he was not authorised to speak about the incident.
"There was an ambush by Boko Haram on soldiers and our colleagues in Hambagda," two kilometres outside Gwoza, said Kolo who also lives in Maiduguri.
More From This Section
"Three soldiers and two Boko Haram fighters were killed in the attack," he said.
News of the attack was slow to emerge because of destruction of telecom masts in the region in previous Boko Haram attacks.
Boko Haram seized Gwoza in July 2014, making it the headquarters of their so-called Caliphate.
Although it was retaken by Nigerian troops in March 2015, the extremists continued to raid nearby villages from their hideouts in the mountains along the border with Cameroon.