NASHVILLE, Tenn. — The Tennessee Supreme Court ruled Tuesday that a special election must be held in May to decide who will fill the remaining term of disgraced former Mayor Megan Barry. The expedited decision puts an end to at least some of the confusion about when voters should go to the polls.

The Davidson County Election Commission now must set a date between May 21 and May 25. The election commission originally set an election date of Aug. 2 — the day that voters were already going to the polls to select some county officeholders.

In the unanimous opinion written by Chief Justice Jeffrey Bivens, the Supreme Court said the August date didn’t meet the legal definition of the required type of election to fill a mayoral term and that the law called for a special election.

Officials have estimated the cost of a special election would be $1 million.

The decision overturns a lower court ruling and it vindicates mayoral candidate Ludye Wallace, who sued, saying the commission set the wrong date.

Barry resigned last month after pleading guilty to felony theft of taxpayer money connected to her affair with the head of her security detail and their travel together. She paid $11,000 restitution and was placed on probation. She was immediately replaced by Vice Mayor David Briley, who is also running to complete her term.