Attorney General Andrea Campbell notified state Auditor Diana DiZoglio on Thursday evening that the auditor’s office lacks the legal authority to audit the Legislature without its consent.

The decision by Campbell deals a major setback to DiZoglio’s crusade to scrutinize the policies and procedures of the House and Senate chambers where she used to serve, but it doesn’t end it. And DiZoglio, in social media posts, indicated she would battle on in the courts and also attempt to change the law via a referendum campaign.

Campbell, who certified the referendum question on the auditor’s powers as legally suitable to go on the ballot, said in her letter to DiZoglio that her analysis represented her interpretation of existing law and is unrelated to the quest for a new law. “Should the initiative become law, we may need to consider whether, and the extent to which, constitutional limitations affect how the law would apply,” Campbell said in her letter.

“I believe transparency is a cornerstone of good government, but that transparency must be achieved through methods that are consistent with the law,” Campbell said. “As the chief law officer of the Commonwealth, it is my office’s role to determine the legal position of the state by looking at the law as it exists on the books today, and evaluating what that law allows, and what it does not. After a thorough review of the statutory text, pertinent Supreme Judicial Court decisions, and relevant history, we have concluded that current law does not allow an audit of the Legislature over its objection.”

Campbell’s letter to DiZoglio was released early Friday morning at the same time that House Speaker Ron Mariano and Senate President Karen Spilka released a joint statement.

“The attorney general’s decision has reinforced our long-held position that the auditor does not have the statutory or constitutional authority to audit any other separate branch of government,” the two lawmakers said.

When she asked the attorney general on July 27 to provide a legal opinion on her office’s ability to audit the Legislature, DiZoglio said she didn’t know what she would do if Campbell didn’t side with her. “We’ll cross that bridge when we come to it,” she said.

In her social media posts on Friday, DiZoglio said she respected Campbell’s “right to her opinion  and to defend the position of legislative leaders. However, a question of statutory interpretation on a matter of such importance to taxpayers is best answered by the courts.”

“Massachusetts has one of the most opaque legislatures in the nation and this decision reinforces the status quo that benefits powerful insiders while leaving working people in dark,” she wrote.

DiZoglio has tapped into a political gold mine with her fight against the Legislature. It helped her in her campaign for auditor, when the former auditor, Suzanne Bump, and the Democrat she supported in the race, Chris Dempsey, said an audit of the Legislature was not allowed under the law.

Once in office, DiZoglio attempted to launch an audit of the Legislature. When she was rebuffed, she went on the attack, asking the attorney general’s office for its legal opinion and launching the ballot campaign. Both moves attracted considerable media attention, but also raised questions about whether her quest was about transparency and good government or whether it was about getting even.

DiZoglio, who has served as an aide in the House, a state representative, and a state senator, has been critical of the way the Legislature operates. The stormy relationship dates to 2011, when she was working as an aide to a House lawmaker. Fired after discredited rumors about her personal behavior surfaced, she negotiated a severance agreement with the speaker’s office that included a nondisclosure agreement barring her from talking about it. She subsequently won election to the House and violated her own nondisclosure agreement in a speech to the chamber where she accused former speaker Robert DeLeo of lying to the chamber.

She has pushed in the House and later as a member of the Senate for elimination of nondisclosure agreements. She also has been critical of the Legislature for its handling of sexual harassment incidents, its inadequate staff pay, and its lack of transparency.

DiZoglio said she has found numerous instances from the past where the auditor’s office conducted audits of the Legislature, but the attorney general’s office said those “reports” by the state auditor’s office, or SAO, didn’t apply to the current situation.

“Despite the existence of numerous SAO reports on certain discrete activities or entities within the legislative branch, we have found no historical precedent at all for the type of audit the SAO seeks to conduct now: a sweeping audit of the Legislature over its objection, which would include review of many of its core legislative functions, namely, active and pending legislation, the process for appointing committees, the adoption and suspension of House and Senate rules, and the policies and procedures of the legislative bodies. To the contrary, historical precedent indicates that the type of audit now proposed has not previously been performed, and prior State Auditors did not believe the SAO to have the power now claimed,” the attorney general’s analysis said.

Campbell’s report said the auditor’s office is a creation of the Legislature and is vested with authority granted to it by the Legislature. “For the reasons set forth in this letter, that authority does not include the power to audit the Legislature itself over the Legislature’s objection,” the letter said. “This conclusion is supported by the statutory text, its legislative history, judicial interpretation of similar statutes, and the historical record. We provide this conclusion in carrying out the role of the Attorney General’s Office to establish a uniform and consistent legal position for the Commonwealth.”