Senegal election: What next after block on President Macky Sall's bid to delay poll?
After more than two weeks of uncertainty, it seems Senegal's checks and balances have kicked in.
President Macky Sall has pledged to organise presidential elections "as soon as possible" after the country's top court, the Constitutional Council, blocked his plans to postpone this month's polls until mid-December.
When Mr Sall initially announced the delay of the election on 3 February - just a few hours before campaigning was due to start - he cited alleged corruption within the Constitutional Council as one of the reasons elections couldn't be held on 25 February, as scheduled.
Mr Sall's party - along with that of one his main opponents, Karim Wade - had levelled accusations of corruption against the Constitutional Court a few days before. They were responding to the exclusion of Mr Wade from the electoral list on the basis that he had dual French and Senegalese nationality when he announced his candidacy, something Mr Wade denies.
Some have argued that the current political uncertainty in Senegal started with the Constitutional Council's decision to exclude Mr Wade, and other opposition candidates, from the ballot.
But the fact that the court has ruled against the president suggests that, despite fears that Senegal might be sliding towards authoritarianism, the rule of law still works.
Mr Sall had been under huge pressure - both at home and abroad - to reverse his decision to delay the polls. Violent, widespread protests have gripped the country. Opposition figures condemned the move, along with influential Muslim leaders.
Senegalese people are proud of their country's reputation as a stable democracy and many felt betrayed by his decision.
In a West African region where four countries are currently under military rule, Senegal is seen by the international community as one of the few examples of a functioning democracy.
With a growing population, increased threats from terror groups and widespread economic hardship, analysts believe strong institutions are needed in West Africa for its citizens to prosper.
As such, many international governments and organisations have a vested interest in promoting good governance and stability in the region.
If Senegal were to become another authoritarian state, many fear the instability that would ensue would threaten regional security at a time when Niger, Burkina Faso and Mali, all run by military juntas, are pulling away from their neighbours and wanting to form their own federation.
Although this latest decision by the Constitutional Council has been welcomed by the opposition and activists alike, the court itself has not always been so popular. In January 2012 it ruled that then-president Abdoulaye Wade (father of Karim Wade) could run for a third term, despite the country's two-term limit.
At the time it argued that Mr Wade's first term in office fell under a previous version of the constitution, which didn't have presidential term limits.
The decision led to weeks of protests, which only ended when President Sall was elected the following month. Ironically, at the time Mr Sall argued that it was impossible for Mr Wade to run for a third term.
"A president cannot extend his term of office, it's not possible," he said during his campaign.
"He can't extend his term even by one day, otherwise the country will be plunged into chaos, because then people would not recognise his legitimacy and there would be no longer any authority in the country."
Mr Sall's critics reminded him of those words in the past two weeks, saying that by delaying elections until the end of the year he had basically given himself a third term.
He strongly denied these charges, saying the delay was intended to calm tensions caused by the exclusion of the opposition candidates.
But there has been suspicion about his intentions for some time, with widespread speculation that he would try and seek a third term in office.
He only confirmed that he wouldn't stand in July last year.
Despite the Constitutional Court's ruling, many Senegalese voters will still be frustrated by the fact that another of Mr Sall's main opponents, Ousmane Sonko, will not be on the ballot.
Mr Sonko was convicted of libel in December, a ruling that disqualified him from running in this year's election. In January the Supreme Court rejected Mr Sonko's appeal against the conviction, making him ineligible to contest the upcoming elections.
A separate, earlier conviction against Mr Sonko led to widespread protests last summer in Senegal, where he is popular with young people who see him as an anti-establishment candidate.
Mr Sonko remains in jail and so does his second-in-command, Bassirou Diomaye Faye, who is nevertheless on the ballot in his stead. Their party, Pastef, has been banned.
Mr Sonko's supporters are unlikely to be satisfied with the Constitutional Council's latest ruling because it makes no provision for the politician to be put back onto the ballot.
Despite Senegal's reputation as a relatively stable democracy, Mr Sall's tenure has been marred with accusations he has rowed back on basic rights, including freedom of expression and assembly.
But with this latest court ruling, Senegal has showed that it can still serve as an example to other West African countries of how to hold their leaders to account.