About 50 Islamist militants have been killed in north-eastern Nigeria after the military raided Boko Haram camps, army spokesman Sagir Musa has said.
Troops tracked gunmen who attacked two towns on Wednesday and Thursday, reportedly killing 20 people.
Boko Haram, which wants to create an Islamic state across Nigeria, has waged a deadly insurgency since 2009.
In May, Nigeria declared an emergency in three north-eastern states in order to battle the militants.
'Invaded from nowhere'
"Troops pursued the terrorists to their camps and destroyed them with air support," Lt-Col Musa said on Friday in Maiduguri - the state capital of Borno state where Boko Haram was founded.
The operation began on Wednesday after gunmen attacked Gajiram, about 75km (46 miles) north of Maiduguri, when it was crowded with traders for market day.
Buildings were burnt and 15 people died in the market, said residents who fled to Maiduguri.
A further five people were killed by gunmen early on Thursday in Bulabilin Ngaura, a small town about 35km south-east of Maiduguri.
"They invaded the village from nowhere. They just opened fire… they killed only five people going to mosque for prayers," a Bulabilin Ngaura resident said.
Boko Haram has not commented on the camp raids or town attacks.
Last month, the army said it had killed Boko Haram's leader Abubakar Shekau but this has not been confirmed and the militants' attacks have continued.
Since the state of emergency was declared, the military has encouraged the formation of vigilante groups to help tackle the Islamists.
In recent weeks, these vigilantes have been the target of attacks.
Observers says it appears Boko Haram is taking revenge against such groups, adding weight to fears that the vigilante groups may trigger an escalation of the violence.