IN LITTLE more than a year the sleepy west African nation of Mali has seen an ethnic uprising, an Islamist insurgency, a military coup, a series of air strikes, the arrival of thousands of foreign troops, including UN peacekeepers, and at last an election on July 28th to re-establish democratic government. Like many observers, Ban Ki Moon, the UN’s secretary-general, has been circumspect about the vote, part of an international plan to sort out the country. “The result, even if the election is imperfect, must be respected by all parties,” he said.

Mr Ban looks unlikely to get his wish. Two days after the vote, Mali’s interior minister announced that the pre-election favourite, Ibrahim Boubacar Keïta (popularly known as “IBK”), had a big lead based on a tally of about one-third of the ballots. The minister added that if trends held, Mr Keïta would pass the 50% threshold necessary to avoid a run-off scheduled for August 11th.

Mr Keïta’s main rival, Soumaïla Cissé, promised to challenge the result in court shortly after the interior minister’s announcement. Mr Cissé’s camp had previously declared a run-off “inevitable”, with Mr Cissé himself alleging “organised fraud” across Bamako, the capital. At some polling stations, Mr Keïta was said to have got more than 90% of the vote.

The election was praised by observers for its high turnout and overall transparency. But coming just six months after a French-led force chased away Islamist militants who had seized control of the country’s vast north, and hastily arranged under intense international pressure, it was nonetheless riddled with flaws. Hundreds of thousands of voters were disenfranchised for lack of new biometric identification cards. Even some who made it to the polls, cards in hand, could not find their names on voter lists.

Still, it was not the debacle many outsiders had forecast. On an otherwise quiet day, voters crowded the streets leading to polling stations. Many marvelled that they had never seen such numbers at the ballot box. The 53.5% turnout shattered the previous record by 15 percentage points. Perhaps most important in a country still jittery after the jihadist occupation of the north, the day passed without violence.

Despite a field of 27 candidates, Mr Keïta’s campaign had taken on an air of inevitable victory in the closing days of the race. On the streets of Bamako, it was hard to find anyone not voting IBK. A headline in one newspaper two days before the election captured the mood. “The donkeys are far behind the horse,” it said above an image of Mr Keïta trailed by two of his main rivals. Having served as prime minister in 1994-2000 and as Speaker of the national assembly in 2002-07, Mr Keïta was seen by many of his supporters as the least objectionable of the candidates. Like him, many of his rivals held posts in previous governments, whose flaws and unpopularity spawned widespread support for a March 2012 coup that ousted Mali’s democratically elected president weeks before an election scheduled to pick his successor.

Mr Keïta has a reputation as a straight-shooter. “If he says yes, it’s yes. If he says no, it’s no,” said Sinaly Touré, a jewellery vendor in Bamako’s artisan market.

That reputation is seen as an advantage in tackling the “northern question”: how to address the ambitions for autonomy of the ethnic Tuareg who live on the edge of the Sahara. It will be one of the main issues for the new president. The Tuareg-led National Movement for the Liberation of Azawad (MNLA), whose rebellion kicked off the crisis in the north last year, is once again pressing its demands for independence. A June agreement with the Malian government allowed the election to go ahead in the Tuareg stronghold of Kidal. In the end, however, some MNLA forces did their best to sabotage the process.

The incoming president will have plenty of other things to grapple with. Mali ranks 182 out of 187 in the UN’s Human Development Index. Its economy, schools and infrastructure are in need of immediate attention. The army must be rebuilt following the coup. The quicker the politicians bury the hatchet, the better.