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.
Babakura Kolo, a member of a civilian militia fighting Boko Haram alongside the military, gave a similar account.
"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.
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 terrorists continued to raid nearby villages from their hideouts in the mountains along the border with Cameroon.
At least 20,000 people have been killed and 2.6 million others displaced since the hardline terrorist group began a rebellion in 2009.