Senegal's president says the delayed election to choose his successor will be held "as soon as possible", after the top court ruled that his attempt to delay it was unconstitutional.
President Macky Sall has served two terms in office.
On Thursday, the Constitutional Council annulled President Sall's decree moving the vote to December.
It also voided the contentious bill passed by parliament which had backed the president's decree.
The move will go some way to restoring Senegal's reputation as a bastion of democracy in West Africa.
Ever since he announced he wanted to delay the elections two weeks ago - just hours before campaigns were meant to kick off, President Sall has been under immense pressure to reverse his decision.
Now that pressure appears to have yielded results, with a statement from the presidency saying Mr Sall will comply with the court ruling - and will also hold talks with all relevant stakeholders without delay, in order to hold elections as soon as possible.
The original date was 25 February - so there is not enough time to hold it then.
A new date for the elections has not yet been given, but in its ruling the Constitutional Council said the president could not stay in power beyond the end of his term on 2 April.
The West African body, Ecowas, France and the European Union all urged Mr Sall to comply with the decision.
Senegal's judiciary has been praised exerting its independence, with a leading opposition figure hailing Thursday's court ruling as "a great day for democracy".
"We've been so ashamed by all this violation of the law and the constitution," former Prime Minister Aminata Touré told the BBC's Newsday programme.
Anta Babacar, the only female candidate, agreed.
"We are actually very, very proud of our Constitutional Council and it shows that there is at least a little bit of democracy and justice that's left in our country," she said.
There had been strong opposition to Mr Sall's decision to postpone the elections until mid-December.
Protesters have taken to the streets and opposition politicians have lodged legal complaints against him.
Religious authorities and regional bodies had also called for elections to be held as soon as possible.
However, the disputes that led to the polls being postponed in the first place remain unresolved, including allegations of corruption in the Constitutional Council and objections from opposition figures who had been excluded from the candidate list published last month.
Holding the election using the disputed candidate list could spark renewed unrest and violence by supporters of those barred from contesting, in particular Ousmane Sonko, who has a large and vocal following among young Senegalese. He is currently in jail after being convicted of various offences after prosecutions, which he says are politically motivated.
Most candidates have not been campaigning since President Sall issued his decree earlier this month.
Senegal is considered one of West Africa's more stable democracies and is the only country in the region never to have suffered a military coup.
BBC