Doug Ford's efforts to slash the size of Toronto's council ahead of an election was ruled unconstitutional on Monday, dealing a major blow to the Ontario premier and plunging the Oct. 22 municipal vote into uncertainty.

In a scathing decision, Superior Court Justice Edward Belobaba said Ford and his Progressive Conservatives interfered with the right to freedom of expression for both candidates and voters when the province enacted the Better Local Government Act last month.

"There is no evidence that any other options or approaches were considered or that any consultation ever took place," Belobaba wrote. "It appears that Bill 5 was hurriedly enacted to take effect in the middle of the city's election without much thought at all, more out of pique than principle. "

Bill 5 cut the size of Toronto's city council from 47 seats to 25, aligning them with federal ridings, despite the fact that the campaign for the fall election was already underway.

City lawyers and others challenging the province contended that reducing the number of councillors in the middle of an election was "discriminatory and arbitrary," and violated the charter -- arguments Belobaba accepted.

The judge acknowledged the importance of exercising judicial restraint when it comes to the decisions of governments but said that in this case, it was appropriate for the court to act.

"It is only when a democratically elected government has clearly crossed the line that the 'judicial umpire' should intervene," he said. "The province has clearly crossed the line."

Ford, who abruptly announced the move in late July, had argued it would improve decision-making on the council. He also said it would save $25 million.

His plan wasn't outlined during the province's spring election campaign or mentioned in the throne speech, but the premier, a failed Toronto mayoral candidate and single-term city councillor, said he had wanted to make the change since his days at city hall.

Ford was set to respond to the ruling on Monday afternoon. Belobaba has noted that he was certain the losing party would appeal.

Toronto Mayor John Tory, meanwhile, welcomed the decision.

"Democracy does not belong to a few of us, it belongs to all of us," he said. "No law should ever fail to take that into account and all of us as lawmakers, regardless of where we're carrying out those responsibilities, should always remember that."

A number of Toronto city councillors also applauded the judgement.

"This ruling on Bill 5 establishes a strong role for the judiciary during times when autocratic governments feel they can just ram through unjust laws," Coun. Joe Mihevic, who is running for re-election, wrote on Twitter. "Governments must follow good democratic processes."

Coun. Kristyn Wong-Tam added that an appeal for the province would be a "steep uphill climb."

"Respect the taxpayer and abort the costly appeal," she tweeted. "Bill 5 is dead. Let it stay dead."

Toronto deputy mayor Stephen Holyday, who supported the council cut, said he thinks the court decision could lead some council candidates to challenge the legitimacy of the Oct. 22 vote.

"As you introduce changes you increase the likelihood of error," he said. "There could be other court cases that spawn out of this."

Holyday said if the matter isn't settled soon, and carries over into the new term of council, it could impact the municipal government's ability to get work done as politics will trump policy-making.

The Canadian Taxpayers Federation, which was one of several intervenors in the legal challenge in support of Bill 5, called the judge's ruling a disappointment and encouraged the Ford government to appeal.

"While the timing of the bill was not ideal ... this bill was introduced nearly three months before the election date, which is still longer than federal and provincial writ periods," CTF's federal director Aaron Wudrick said in a statement. "Waiting an additional four years to reduce the size of city council is a missed opportunity to save taxpayers money."

But the Canadian Union of Public Employees, which provided funding to one of the groups challenging the province, called Belobaba's decision a victory for democracy.

"When Doug Ford tried to ram through this bill, he tried to silence newcomers to the political process and underrepresented voices," CUPE Ontario President Fred Hahn said in a statement. "Many candidates, particularly people of colour, LGBTQ, and young candidates, who have put their lives on hold to run for office, will now get their fair chance to express themselves in a free and fair election."

Green party Leader Mike Schreiner said the decision confirms that not even Ford is "above the law."

"Ford's efforts to put ideology above evidence and his personal agenda before democracy have real world consequences," he said in a statement. "Thankfully, the courts have put a check on the premier's undemocratic actions for the second time now."

Toronto city staff said they will proceed with the election on the basis of a 47-ward structure. Advance voting starts on Oct. 10.

Bill 5 also cancelled planned elections for the head of council position in the regional municipalities of Muskoka, Peel, York and Niagara, turning them into appointed roles. Belobaba said his ruling does not impact that aspect of the bill.