Boko Haram, a jihadi group seeking to establish a sharia-based state in northern Nigeria, has made little secret of the fact that it regards itself not only at war with the Nigerian state, and its security forces, but its people too. It has bombed churches, mosques, carried out assassinations, kidnapping, and mass assaults. On a single day in January last year, it killed 185 people across Kano. As the years have gone by, the ferocity, ambition and scale of its attacks have increased. In Bama, earlier this month, a group of about 200 men in armoured vehicles mounted with machine guns stormed military barracks, a police station and government buildings, killing 55 people and freeing 105 prisoners. Any government would have to respond to this.

The question behind the state of emergency declared by President Goodluck Jonathan in the three northern states this week is not why – it is how. States of emergency have been declared before, and troops have been deployed. The announcement this week represents Nigeria's version of the US surge in Afghanistan. It is therefore critically important that it should have a different outcome. It is difficult to talk about the trail of destruction Boko Haram has left without mentioning the military's indiscriminate response. As Human Rights Watch has chronicled, a military raid on Baga in April left 2,000 burned homes and 183 bodies. The Nigerian military not only denies the figures, and refuses to investigate, but says if there were atrocities they were carried out by insurgents. No one is denying that it has a brutal enemy to fight. But the terrified civilians caught in the middle have to be able to distinguish the actions of terrorists and the actions of government. As things stand, that is hard to do.

In Maiduguri, the town where Boko Haram first emerged, you have a choice: to be gunned down by Boko Haram or by the military. What you cannot do is seek the military's protection, without being considered one of the enemy it is fighting. Its a well known catch-22 of anti-insurgency warfare. Either you are an insurgent, in which case you are summarily executed, or you are not one, but deemed to be sheltering them, in which case the same fate awaits. Boko Haram, which has used poor students enrolled for religious studies from Chad and Niger as soldiers, has had few problems with recruitment. And there is sympathy in the north with a state based on sharia law.

With an election coming, Mr Jonathan has to respond to the security threat. But he has to do so discriminately, proportionately and within the law of the land. Soldiers have to be subject to it, too. Otherwise they are merely feeding the insurgency they are there to suppress.