Army spokesman Colonel Muhammad Dole said troops on patrol foiled a planned attack on local residents and a military camp in Damboa, Borno state, in the early hours, and inflicted "heavy casualties".
"While the encounter lasted, 38 Boko Haram terrorists were killed and some fled with various degrees of injuries," the officer said in an emailed statement, adding that three vehicles were destroyed.
One of the vehicles was found to have cylinders and improvised explosive devices. Weapons and ammunition, including machine guns, were also recovered, he said.
"Combined ground troops and Nigerian Air Force aircraft are tactically pursuing the fleeing terrorists in the ongoing operation in the general area of Damboa and surrounding villages," Dole added.
Also Read
Damboa is nearly 90 kilometres (55 miles) southwest of the Borno state capital, Maiduguri.
Boko Haram, deemed a terrorist organisation by the United States, has been fighting a bloody insurgency in Nigeria's north since 2009, attacking schools which follow a "Western" curriculum and churches as well as military and police targets.
Nigeria's government in May last year imposed a state of emergency in Borno and two other neighbouring states, Yobe and Adamawa, in an attempt to stem the violence, which has claimed thousands of lives.