Ontario’s highest court handed the provincial government a legal victory on Wednesday that will allow it to move ahead with its plans to cut the size of Toronto’s city council by nearly half just weeks from a municipal election.

A panel of three Court of Appeal justices stayed a lower court’s ruling that struck down as unconstitutional legislation introduced by the Progressive Conservative government of Premier Doug Ford to reduce the size of the council from 47 to 25 members.

The decision means city staff will immediately begin preparing for a 25-ward election Oct. 22.

The province had argued the stay was necessary to eliminate uncertainty surrounding the upcoming vote, and the Court of Appeal agreed.

“It is not in the public interest to permit the impending election to proceed on the basis of a dubious ruling that invalidates legislation duly passed by the legislature,” the three-judge panel wrote.

Superior Court Justice Edward Belobaba found last week that the province’s Bill 5 violated freedom of expression rights for candidates and voters.

Premier Ford contested the ruling and took the unprecedented step of invoking the notwithstanding clause, a constitutional device that allows provinces to temporarily ignore court rulings in certain exceptional circumstances, and reintroduced the legislation to push through with his plan.

The Court of Appeal sided with Ford.

“Unquestionably, Ontario’s announcement of its intention to introduce Bill 5 disrupted the campaigns that were already underway,” the court ruled. “However, Bill 5 does not limit or restrict any message the candidates wish to convey to voters for the remainder of the campaign.”

With files from The Canadian Press