Boko Haram has "legitimate grievances" and Nigeria should not rule out talking to the terrorist group – but only after a sustained military campaign, former Nigerian president Olusegun Obasanjo has said.

Obasanjo, who led Nigeria in the 1970s as military ruler and as president from 1999 to 2007, said that both carrots and sticks were needed in dealing with Boko Haram, who recently pledged allegiance to Islamic State (Isis) and last year kidnapped hundreds of Nigerian schoolgirls, many of whom remain in captivity.

The kidnapping led to a global campaign online #BringBackOurGirls, backed by Nobel prize-winning Pakistani schoolgirl Malala Yousafzai and Angelina Jolie, and criticism of the Nigerian government for its failure to rescue the girls and to tackle the rising violence of Boko Haram in Nigeria's lawless north east.

In recent months, a spate of suicide attacks by the group in Nigeria have left hundreds dead.

In an interview with IBTimes UK on the sidelines of the Global Education Forum conference in Dubai, Obasanjo said that while 79% of Nigerians received education in the south west of the country and 77% in the south east, in the Boko Haram stronghold of the north east that figure was just 19%.

"We don't need [anyone] to tell [us] that that is a problem. A problem of disparity, a problem of marginalisation. A problem because education is fundamental to your employability, to your living conditions. If you are not educated you are handicapped," he said.

But he said that while improving access to education was the carrot, the stick had to come first, and criticised the current administration of President Goodluck Jonathan for failing to act fast enough in taking the fight to Boko Haram. That failure, he said, had given the group confidence to spread to neighbouring Chad and Cameroon.

"The response of the government initially was definitely not enough. When Boko Haram started showing their fangs about four years ago the reaction should have been firm and unmistakable. We have lost ground," he said.

Obasanjo said that the spread of Boko Haram into other countries had provoked a regional response and that both Chad and Cameroon were involved in the military campaign against the terror group.

But he added that once progress had been made, Nigeria should not rule out engaging with the militants.

"If Boko Haram is ready to talk, [we should talk]. But by the time they are ready to talk they will need to be pounded a little bit militarily: at that stage they will be ready to talk," he said.

A one time ally of President Jonathan, Obasanjo led Nigeria as military ruler for three years from 1976 to 1979 and then as an elected president from 1999 to 2007. He was responsible for transitioning Nigeria to democracy for the first time in 1979, even if a military coup in 1983 brought an end to that brief reprieve.

He publicly spilt with Jonathan earlier this year, when he gave back his membership card of the Peoples Democratic Party (PDP) and instructed a former colleague to tear it up on live TV.