Nigeria is at war. In the past week alone the Islamist militants Boko Haram have slain hundreds, perhaps thousands, of people across north-eastern Nigeria, some with the help of child suicide bombers, including a 10-year-old girl. In recent months they have sacked entire towns and villages, and are now masters over 20,000 square miles of territory.

About 1.7 million people now live in Boko Haram’s declared “caliphate”, while 1.5 million have been displaced from their homes as a result of the violence. With a month to go before presidential elections, Africa’s most populous country is losing the war against a fullblown Islamist insurgency. So what is the Nigerian government doing about it?

In 2013 President Goodluck Jonathan, who is up for re-election, declared war on Boko Haram and dispatched the Nigerian army to battle them. But Boko Haram not only fended off the army’s offensive, it ended up being emboldened by the obvious ineptitude of the Nigerian forces. Soldiers meant to be protecting cities and towns have sometimes taken to their heels when Boko Haram’s fighters arrived on the scene, leaving inhabitants at the mercy of the Islamists.

But the problem isn’t that Nigerian soldiers are cowardly, it is that they are woefully under-equipped, under-trained and far too demotivated to tackle the well-armed Boko Haram fighters. The governor of Borno, the state most affected by Boko Haram, has publicly stated that the Islamists are much better armed than the soldiers.

The reason the Nigerian army is in such poor shape is simple: corruption. The military’s annual budget exceeds £4bn, but rather than equip and train frontline troops, there are complaints that much of the funds end up in senior officers’ pockets. Soldiers who complain have been known to be court-martialed and sentenced to death for “mutiny”.

As commander-in-chief, this is where Jonathan could have been expected to step in. But rather than confront the army top brass the Nigerian president has opted to bury his head in the sand and place the blame for Boko Haram’s success on everyone bar himself. When news emerged last year of the kidnap of the Chibok girls, instead of reacting swiftly Jonathan hesitated for two weeks, suggesting there was no kidnap, only a plot by his political opponents to discredit him.

At other times he has shrugged off Boko Haram’s deadly attacks as little more than the unavoidable localised version of global jihad, implying with his tone and body language that hundreds of citizens getting killed every week is something Nigerians will simply have to get used to. After a deadly bomb blast killed more than 100 people in the capital Abuja last year, Jonathan was pictured dancing away at a political rally the next day.

Travelling around the country over the past few weeks, my impression is that Nigerians are increasingly looking to the main opposition presidential candidate, Muhammadu Buhari, a former general and one-time military ruler, as the country’s best hope of tackling Boko Haram. Under “normal” conditions Buhari, a conservative Muslim from the north who ruled Nigeria with an iron fist from 1983-85, would have little hope of support in the country’s southern, predominantly Christian region. Without outstanding charisma, eloquence or competence on policy detail, the 72-year-old Buhari has already made three unsuccessful bids for president.

But after a year in which Boko Haram and government corruption has dominated local headlines, the ex-general has two things going for him: a reputation for strong leadership and incorruptibility. He is probably the only prominent Nigerian politician today who isn’t hounded by allegations of embezzling public funds.

A president with military experience to take on corrupt army officers would surely serve as a morale booster to the Nigerian soldiers battling Boko Haram. Granted, the ex-general has no magic wand to make the militants simply vanish. But in this period of existential crisis, Nigeria may need a wartime leader who can project reassuring strength and provide a plausible strategy for overcoming the insecurity in the country. Time is running out.