TORONTO -- No evidence exists that Ontario Premier Kathleen Wynne or any of her senior ministers acted in bad faith when they made the surprise decision to privatize part of provincial utility Hydro One, the province's top court ruled on Tuesday.

Upholding an earlier ruling dismissing a lawsuit against the province, the Ontario Court of Appeal agreed the Liberal government's decision is immune to such legal action because the privatization was a matter of "core policy."

As a result, the plaintiffs would have had to show detailed evidence the decision was either irrational or made in bad faith, the Appeal Court said in a ruling that comes just months ahead of an election in which the privatization is likely to be a key issue.

"Matters of core policy are supposed to be immune from suit, absent rare cases of irrationality or bad faith," the Appeal Court said. "The appellants say that a great deal will be revealed if the suit is permitted to proceed and discovery takes place, but to accept the pleading in order to facilitate discovery would be to undermine the important purpose of the immunity."

The case arose when the Wynne government decided to sell off part of Hydro One -- a decision that had gone completely unheralded during the provincial campaign that returned the Liberals to office in 2014. The government said money from the sale of shares would go to pay down long-term hydro-related debt and fund transit and other infrastructure projects.

The Canadian Union of Public Employees and other ratepayers sued Wynne along with her energy and finance ministers, arguing the privatization plan was merely a scheme to reward donors to the Liberal party as a way to keep the donations flowing. As such, they said, the government had acted in bad faith.

Last August, Superior Court Justice Peter Cavanagh dismissed the suit without a trial, saying he had found no evidence to support the claim of bad faith.

The plaintiffs appealed, arguing Cavanagh had made several mistakes. Among his purported errors, they argued their claim did in fact support a bad-faith conclusion that should at least have been dealt with at trial.

The Appeal Court, however, found no reason to disagree with Cavanagh given the law about using the courts to challenge policy decisions governments make. Simply alleging officials acted in bad faith or for partisan political purposes, the court said, is not enough.

"Decisions based on political expediency are to be expected," the Appeal Court said. "The check on them lies in democratic, not judicial, oversight."

The sale obviously required "considerable assistance" from paid professional advisers, the higher court said, and the "bald allegation" that the privatization was a veiled scheme to reward party donors didn't meet the bad-faith threshold that might have opened the door to the action.

As Cavanagh found, accepting that the government had been dishonest without detailed supporting evidence would undermine protections afforded to core policy decisions, the Appeal Court said.

"He did not reject the pleadings on the basis that they were simply an objection to the policy being pursued," the Appeal Court said. "He found that they were precisely the sort of objections to which the immunity was intended to apply."

In light of its findings, the higher court also said it was unnecessary to decide whether the claim was barred by parliamentary privilege or constituted an abuse of the court's processes -- as the government had argued.