State Auditor Rebecca Otto on Thursday sued three counties over a new law that allows counties to outsource financial audits, calling it an “unprecedented effort to privatize a core function” of her office.

The lawsuit, filed in Ramsey County District Court, is asking a judge to preserve her office’s “constitutional authority” to audit counties in ­Minnesota or declare the new law unconstitutional. It named Becker, Ramsey and Wright counties as defendants, which were among 50 counties that refused to sign a three-year auditing contract with Otto’s office.

The lawsuit originally named the state of Minnesota as a defendant, but in a court filing Thursday, the state was dropped. The attorney general’s office said the state “was not a proper party” to the suit.

If the new law stands, “it will have a devastating effect on the [auditor’s office], including layoffs, lost talent and experience, a substantially smaller budget, and the loss of primary responsibility of the office,” the lawsuit says.

Otto’s lawsuit is the latest flash point in an increasingly testy disagreement with some legislators, who approved the change in the final, frantic hours of the legislative session last year. The change gave all 87 Minnesota counties the option of hiring private firms for financial audits rather than using the state auditor’s office, which some county officials say is more expensive.

The law was the result of an apparent deal cut by House Speaker Kurt Daudt, R-Crown, and Senate Majority Leader Tom Bakk, DFL-Cook, according to two state senators who said they were strong-armed into approving the change.

Otto, a DFLer, issued a statement explaining her decision to file the lawsuit, which is being paid for by taxpayers. “The privatization legislation was passed as part of a bad legislative process,” she said.

Rep. Sarah Anderson, R-Plymouth, called the lawsuit frivolous, criticizing the use of taxpayer money to pay for the legal challenge. “This is a complete waste of time and money,” she said.

Bakk declined to comment due to the pending litigation.

DFL Gov. Mark Dayton, who once served as state auditor, sides with Otto. “I believe the Minnesota Legislature unwisely and improperly encroached upon the State Auditor’s constitutional responsibilities to audit local governments,” he said in a statement.

Otto in recent months had been weighing her legal options, spending more than $100,000 in legal fees. Her decision came after Legislative Auditor Jim Nobles issued a report saying it was too early to tell whether Otto’s office was less efficient than private accounting firms when reviewing counties’ books.

The auditor’s office is composed of about 92 employees, and is charged with reviewing $6 billion in annual spending of federal, state and local dollars by counties. More than half the office’s staff audit counties, and about 60 percent of its funding is derived from auditing fees.

Since 2003, the state auditor’s office has determined which of Minnesota’s 87 counties would undergo an audit by the state and which could hire a private firm. The arrangement was spawned from budget cuts that limited how many audits the state could conduct. The last three-year audit cycle ended in 2014, and Otto’s office notified 61 counties that the state would be auditing them from 2015-2017, according to the lawsuit.

Of those, 50 counties refused to sign a contract, a loss of about $3.9 million, about 44 percent of the auditor’s budget, according to the lawsuit. Fred Morrison, a University of Minnesota Law School professor, said the state Constitution does not explicitly outline the duties of the state auditor, a role that has existed since before statehood. The state auditor has performed different duties over its more than 150 year history, but the power to audit counties was not granted until 1973.

The Legislature then restructured government, shifting the auditor’s duties from approving executive branch spending to auditing counties, a job previously performed by the now-defunct public examiner’s office.

“The auditor faces an uphill battle,” Morrison said. “The [Minnesota Supreme Court] has given the Legislature broad latitude in structuring the government, even if it involves taking away some of the powers. What is different about this one is that it takes away virtually all of the authority the auditor has.”

County officials named in the suit said it was unfair for Otto’s office to pressure them to sign three-year contracts. Becker County Administrator Jack Ingstad said officials in his county preferred audits conducted by private firms, which he said cost a fraction of what Otto’s office charges.

Otto defended her lawsuit, saying her hand was forced. “It’s time for the courts to weigh in,” she said.