On Tuesday, with public attention fixed on a primary election, attorneys filed a document in federal court detailing an agreement few had anticipated — Mayor Rahm Emanuel’s administration had signed off on allowing groups including Black Lives Matter Chicago to consult on and seek to enforce a court agreement that will govern reforms in the troubled Chicago Police Department.

That was an about-face for an administration that previously had argued to dismiss litigation from those same groups seeking change in the police force. The city instead has been hammering out a court-backed slate of changes — known as a consent decree — with the office of Attorney General Lisa Madigan, who also sued the city to force change.

Now, the activists and advocacy groups will share influence in the process with city and state officials. Some of those activist groups take positions unlikely to appeal to the local political elite; Black Lives Matter Chicago, for example, advocates for de-funding the police and criminally prosecuting Emanuel, among others, in the alleged “cover-ups of the murders” of people by police.

While the news may have come as a surprise, the benefits of the deal to each party are clear — as are the risks the participants would have faced without the agreement.

For the city, the deal means that groups including the NAACP and ACLU of Illinois, and their army of lawyers, will suspend their lawsuits and join the negotiating process. If those lawsuits had continued, they might have dragged on through the 2019 mayoral election. Emanuel is seeking a third term and could face challengers who might seek to capitalize on some voters’ dissatisfaction with the police.

For the activists and advocacy groups, the agreement gives them influence they might not have won through their lawsuits. Their litigation could have failed, preventing them from forcing change in an agency that the U.S. Department of Justice found to be prone to misconduct and excessive force, often against minorities

The agreement, however, comes with political risks of its own, and it was immediately unpopular with some in law enforcement. A statement from Chicago Fraternal Order of Police President Kevin Graham said the agreement would “go nowhere” without the support of rank-and-file cops. The FOP is in contract negotiations with the city, and Graham said police would “never give up (their) collective bargaining rights.”

Second City Cop, a blog catering to law enforcement, derided the agreement as a plan to “give terrorists a seat at the table.”

In a statement, Law Department spokesman Bill McCaffrey said the city “entered into these agreements to provide a formal process for these groups to share input and have productive conversations regarding the consent decree negotiations.”

“The agreements also suspend the ongoing litigation in the two pending cases and allow us to instead focus our time and resources on finalizing the consent decree with the Illinois attorney general and reforming the Chicago Police Department,” he wrote.

McCaffrey said the city had “offered the same process” to the police unions, though no similar arrangements had been reached.

FOP spokesman Martin Preib did not respond to a request for further comment beyond Graham’s statement.

The “memorandum of agreement” filed Tuesday codifies a deal between Madigan’s office, city officials and the plaintiffs from the two lawsuits, which include well-known organizations such as the ACLU of Illinois and Chicago Urban League, along with lesser known groups. Those groups had filed lawsuits complaining of police brutality and unfair treatment of African-Americans, Latinos and the mentally ill and disabled.

It was unclear why the court filing was made on primary election day, though releasing important information while the media and public are distracted is a common tactic among local political officials hoping to bury news. The agreement was announced in a press release from the ACLU of Illinois.

The agreement holds that the activists and advocacy groups will explain their grievances to representatives from the city and attorney general’s office and make proposals for the consent decree, and attorneys from the parties will meet to discuss the proposals and negotiate over them. Once a consent decree is written, the plaintiffs will get to see the document and give feedback.

The implementation of a consent decree is typically overseen by an appointed monitor, and the agreement holds that the yet-to-be-selected monitor who presides over Chicago’s consent decree will meet quarterly with the plaintiffs apart from the city and attorney general’s office.

The city and attorney general’s office also agreed not to contest the plaintiffs’ standing to seek court enforcement of the decree if the city fails to comply with it.

The plaintiffs, meanwhile, agreed to stay their lawsuits. One of the lawsuits includes the allegations of several individual plaintiffs, and their claims seeking money damages will not be stayed.

Sheila Bedi, a Northwestern University Law School professor and attorney who helped lead one of the lawsuits, said the agreement gives the activist groups real influence over changes to the Police Department.

“We can use the power of the federal court to try to ensure that the consent decree is really robust,” she said.

The agreement is the latest consequence of the political controversy sparked in late 2015 by the court-mandated release of video of white police Officer Jason Van Dyke shooting black teenager Laquan McDonald 16 times. The video touched off street protests fueled by long-standing complaints about the police, particularly among African-Americans and Latinos, and Emanuel weathered calls for his resignation.

Emanuel at first resisted the idea of a Justice Department investigation but reversed himself as it gained momentum among other political officials. The resulting investigation wrapped up in January 2017 with a report describing a broken Police Department in which poorly trained cops have engaged in brutality and misconduct with little to fear from either their supervisors or a largely toothless disciplinary system.

In the last days of an Obama administration that often sought to enforce reform in local police agencies, Emanuel supported a court-enforced consent decree to govern changes in Chicago. But he backed off after the Trump administration came into office and expressed opposition to consent decrees. Emanuel said he could bring meaningful reform to the department through an out-of-court agreement with the Trump administration involving a monitor.

Then, in August 2017, Madigan sued the city to force a consent decree, and Emanuel said he would negotiate toward one. Black Lives Matter Chicago and other groups had sued months before to force changes in the department; the ACLU of Illinois and other organizations sued in October 2017 to force reforms in the way police deal with the mentally ill and disabled.

The Emanuel administration started working with the attorney general’s office while moving for the dismissal of the other lawsuits. Judges had not ruled on those motions before Tuesday’s agreement.

The agreement holds that if the consent decree is not filed by Sept. 1 or entered by a judge by New Year’s Day 2019, the plaintiffs can move to lift the stays on their lawsuits. Those deadlines have extra meaning, given that Madigan is not seeking another term and will leave office in January 2019.

Many cities have been through the process of court-enforced police reform, but the new agreement in Chicago is unusual in that community groups and advocacy organizations are having their role formally recognized in a court document before the consent decree is finalized, said Christy Lopez, a former Justice Department lawyer who helped lead the investigations in Chicago and other cities.

Still, community groups and activists were involved with the reform cycles in other cities, said Lopez, who described the negotiation process between politically disparate parties as both difficult and rewarding.

“It’s very challenging, and there are reasons they haven’t come together in the past,” she said. “What you have to do, obviously, is find the areas in which they can agree, and really focus on those.”