But an officer, speaking on condition of anonymity, said the militants had overrun an army base, and put the death toll at 18.
An army statement said the attackers ambushed a military convoy late Monday on a highway linking Maiduguri, the capital of Borno state, with Damaturu in neighboring Yobe state, Presstv Reported.
"Sadly, 13 military and a police personnel... paid the supreme price while extricating themselves from the ambush," said the statement, signed by local military spokesman Colonel Onyema Nwachukwu.
The attack followed an attempted raid on a nearby military base along the highway in Kukareta village, 20 kilometers (12 miles) from Damaturu, Nwachukwu said.
That attack was "repelled" by troops who "engaged and overpowered the terrorists, killing several of them", Nwachukwu said, adding that a soldier was injured.
Other security sources said fighters travelling in eight trucks fitted with anti-aircraft guns had overrun the base.
"The terrorists killed 17 soldiers in the attack, which lasted for more than an hour," an officer told AFP on condition of anonymity.
"They took over the military base after overpowering troops and burnt it down. A policeman was killed when their vehicle which was heading to Damaturu ran into crossfire but the driver escaped unhurt," the military source said.
A medic in Damaturu hospital said 18 bodies were taken to the morgue late Monday.
A civilian militiaman in the area gave a similar account and said the fighters withdrew after torching the base.
"They burnt the base and two military vehicles. They also burnt two primary schools in Kukareta and neighboring Ngaurawa village," said the militiaman.
Boko Haram extremists have carried out dozens of attacks on military bases in recent months. Scores of soldiers have been killed or listed as missing.
The 120-kilometre (75-mile) Maiduguri-Damaturu highway has seen repeated attacks, including raids on military bases and markets.
In September 2013, Boko Haram fighters disguised as soldiers barricaded the highway and killed 167 people, in the worst attack targeting motorists.
The nine-year-long insurgency has killed 27,000 people and displaced two million more, creating a dire humanitarian crisis.
The conflict has spilled over into Nigeria's northern neighbors Chad, Niger and Cameroon.