An Ontario judge has struck down the provincial government’s efforts to slash the size of Toronto city council in the middle of an election, saying the move violated constitutional rights.

In a decision handed down early Monday, Superior Court Justice Edward Belobaba said Premier Doug 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.

Bill 5 slashed 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 Oct. 22 election was already underway.

Belobaba sharply criticized the bill in his decision.

“There is no evidence that any other options or approaches were considered or that any consultation ever took place,” he 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. “

The judge accepted arguments from city lawyers, who contended that reducing the number of councillors in the middle of an election is “discriminatory and arbitrary,” and violated the charter.

Belobaba 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.”

He noted that the province’s imposition of Bill 5 had two “constitutional deficiencies” that can’t be tolerated in a free and democratic society.

“The first relates to the timing of the law and its impact on candidates,” he said. “The second to its content and its impact on voters.”

Ford had argued the move would improve decision-making on the council, where he served one term. He also said the move would save $25 million.

The premier is set to respond to the ruling at noon.

Belobaba said last month that he was certain his decision would be appealed by the losing party.

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.”

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.