Boko Haram militants fleeing a Nigerian army offensive killed 21 people on Friday in attacks near the northern village of Chibok, close to where the rebels abducted more than 200 schoolgirls last year, a military source said.
The rebels were fleeing a land and air offensive to clear them out of the Sambisa forest when they raided the villages of Gatamarwa, Makalama and Layhawul and opened fire on terrified residents, the source said.
Boko Haram fighters in many parts of Nigeria and the region are on the run, after being subjected to a major military offensive on all sides by Nigeria and its neighbours Chad, Cameroon and Niger.
Nigerian warplanes bombarded insurgent training camps and caches of their weapons and vehicles in Sambisa on Thursday.
But when Boko Haram, which is fighting to carve an Islamic state out of Africa's biggest economy, feels threatened, the civilian population often becomes a target. The security source said the insurgents fleeing the Sambisa operation had taken revenge on the civilian population.
"They surrounded the market and started shooting," said Chibok resident and farmer Maina Chibok, who visited the Gatamarwa area afterwards. "There was pandemonium everywhere and more than 10 people were killed."
"POCKETS TO FLUSH OUT"
For most of the past year, Boko Haram has been gaining strength, seizing territory the size of Belgium and kidnapping hundreds of people, mostly women and children. But victories against them have gathered pace in the past three weeks.
Nigeria's neighbours, where Boko Haram used to flee, are pursuing a strategy of pushing them back into Nigeria.
Colonel Moussa Barmou of Niger, the coordinator of the joint Niger-Chad mission, told the state-owned Le Sahel daily that operations had "dismantled all the supply and recruitment networks of the terrorist group" in Niger, the most obvious path of retreat for Boko Haram into the Sahara if Cameroon and Chad keep up the pressure.
"There remains much to do ... but slowly, we are getting there," he said. "There are still some pockets to flush out."
The villages attacked are in the local government area of Chibok, where in April last year heavily armed Boko Haram militants attacked a girls' secondary school at exam time and drove pupils away in trucks.
The attacks triggered global outrage and President Goodluck Jonathan, who faces an election on March 28, was pilloried for his perceived slow response to the crisis.
The girls remain in captivity, but recent military successes against Boko Haram would likely play in his favour. His rival for the presidency, former military ruler Muhammadu Buhari, is seen as tough on security.
The plight of the Chibok girls has become symbol of the devastating toll the Boko Haram insurgency has exacted on defenceless civilians, who have been massacred in their thousands.
The crisis has also spawned more than a million internal and external refugees, who have trekked through deserts, crossed rivers and hidden in forests to escape to the relative safety of ever swelling refugee camps