Military spokesman Sagir Musa said 32 of the militants were killed and two soldiers and a policeman lost their lives during the clashes.
"Our troops successfully repelled Boko Haram terrorists who tried to attack a police base on Sunday," he said.
He said a military base in Malam Fatori town came under attack from the militants and a gun duel ensued.
The oil-rich African country's President Goodluck Jonathan had declared a state of emergency in three states of Borno, Adamawa and Yobe, four years after militant group Boko Haram declared war on the Nigerian state.
Nigeria's 150 million people is evenly distributed among Christians and Muslims.