The decision to postpone this month's elections in Senegal is against the country's constitution, the country's top court has ruled.
The Constitutional Court annulled President Macky Sall's decree and a contentious bill passed by parliament moving the vote to December.
Widespread protests have gripped the West African country, once considered a bastion of democracy in the region.
Opposition figures said it amounted to an "institutional coup".
Mr Sall had announced he was pushing the election back because of what he claimed were concerns over the eligibility of opposition candidates.
His proposal had been backed by 105 out of the 165 MPs. A six-month postponement was originally proposed, but a last-minute amendment extended it to 10 months, or December 15.
Mr Sall had reiterated that he was not planning to run for office again. But his critics accused him of either trying to cling on to power or unfairly influencing whoever succeeds him.
Opposition candidates and lawmakers, who had filed a number of legal challenges to the bill, will likely feel vindicated by the court's decision on Thursday evening.
Khalifa Sall, a leading opponent and a former mayor of the capital Dakar, who is not related to the president, had called the delay a "constitutional coup" while Thierno Alassane Sall, another candidate, also no relation, called it "high treason".
The court said it was "impossible" for the election to be held on the originally intended date of 25 February - just 10 days time - but urged authorities to organise it "as soon as possible".
Most candidates have not been campaigning since President Sall issued his 3 February decree, hours before campaigns were meant to kick off.
The court decision comes on the same day as several opposition politicians and civil society members were released from prison, in what some in the country viewed as a move to appease public opinion.
Senegal had long been seen as one of the most stable democracies in the region. It is the only country in mainland West Africa that has never had a military coup. It has had three largely peaceful handovers of power and until earlier this month had never delayed a presidential election.
President Sall has been in power since 2012, with his second term in office due to end this April.