The Minnesota Supreme Court ruled against State Auditor Rebecca Otto Wednesday, ending her long legal effort to block a 2015 law that lets counties hire outside accountants rather than her office.

Otto, a DFL candidate for governor, had argued that the law undermined her authority. She sued Becker and Wright counties after they hired CPA firms and challenged Ramsey County's refusal to sign a three-year contract ensuring that her office had the sole right to conduct audits.

The ruling was an important affirmation of her office's power to conduct county audits — even after they have been done by outside firms — and examine all accounts and records, Otto said Wednesday.

The high court's opinion also warned the Legislature not to attempt to "gut" a state office, she said. In January, Otto told the Supreme Court that the law turns her office into "an empty shell."

On Wednesday, she said that the court "provided some very important clarifications for everybody."

Scott Anderson, an attorney with Rupp, Anderson, Squires and Waldspurger, represented Becker and Wright counties. He called Otto's claim "putting a spin on what is a loss."

Anderson noted that Otto's office already gives permission each year to fewer than 30 of the state's 87 counties to hire outside auditors. "We could find no instances where the state auditors had records indicating that they found private CPA audits to be deficient such that they had to do them over," he said.

The conclusion of the case didn't end tensions between Otto and GOP legislators.

Rep. Jim Nash, R-Waconia, said Otto "was unable to see that the Legislature has the ability to change laws."

Nash said on Twitter that Otto spent more than $250,000 "in a capricious lawsuit" — funds he said would have been better spent on auditing pensions and other priorities.

Otto defended the cost to taxpayers. "I will stand up for what's right, not what's politically expedient, and I don't regret it," she said.

Otto noted that the Legislature has spent about $400,000 on its court battle over a line-item veto of its operating budget by DFL Gov. Mark Dayton.

Anderson said the two counties together spent less than $140,000.

Rep. Sarah Anderson, R-Plymouth, chairwoman of the State Government Finance Committee and chief author of the 2015 law, said the fight was worth having. The bill "passed with broad bipartisan support," she said, calling Otto's assertion that counties can't hire outside firms "ridiculous."

She said a pending omnibus bill includes language requiring use of industry standard auditing procedures. "What I'm concerned with now going forward is that she's not doing a punitive audit of some of these counties," she said.

The justices on Wednesday upheld rulings by a district court and the Minnesota Court of Appeals.

Their opinion concluded that the 2015 law did not violate the separation of powers clause in the Minnesota Constitution, nor a clause requiring that bills at the Legislature deal with a single subject.

The high court concluded that under the law, the state auditor "retains significant duties and responsibilities in connection with audits of Minnesota counties," according to the opinion written by Chief Justice Lorie Skjerven Gildea in agreeing with the appeals court.

Judy Keen • 612-673-4234