More than a decade after he loosened a set of rules surrounding New York Police Department surveillance, a federal judge did something unexpected last week: He rejected a lawsuit settlement between the city and plaintiffs alleging years of unlawful spying in Muslim communities, arguing it did not go far enough in reining in law enforcement overreach.

In a 41-page ruling delivered last Monday, Judge Charles Haight Jr. argued that due to the NYPD’s “systemic inclination” to flout rules governing its surveillance practices, he could not approve a settlement the city had spent more than a year hammering out with civil liberties attorneys.

In lieu of approval, the judge proposed three recommendations to strengthen the role of a proposed civilian representative tasked with providing oversight in certain NYPD investigations. Each suggestion had been proposed during settlement negotiations, lawyers for the plaintiffs said, but were rejected by the city and left out of the final settlement proposal.

“I certainly wasn’t expecting this,” Jethro Eisenstein, an attorney for the plaintiffs, told The Intercept. “From our point of view, we rolled the rock up the hill as far as we could take it.”

Eisenstein described the judge’s ruling as a sign of encouragement. “He’s saying, ‘No, it has to go further.’”

The view from New York City officialdom has been less glowing. In a statement to the press, the city’s legal department said it was “disappointed” with elements of the judge’s decision-making but added that it “will explore ways to address the concerns.”

Judge Haight’s ruling was the final act in a process that began in April in which the public was invited to weigh in on the settlement and the proposed changes to NYPD surveillance practices.

The historic litigation had brought together two separate legal challenges. The ACLU and the CLEAR Project at the City University of New York filed one of the cases in June 2013. The plaintiffs in that case, known as Raza v. the City of New York, included two well-known New York City imams, two mosques, and a Muslim college student whose circle of friends was infiltrated by an NYPD informant.

The second case, Handschu v. the City of New York, is a class-action suit that has served as a civil liberties and public security bellwether for generations. The suit was filed in 1971 in response to years of NYPD surveillance targeting anti-war protesters, the Black Panthers, the ACLU, the NAACP and others. Eisenstein, the lawyer who welcomed the recent decision, was 26 years old when he sat down at his typewriter to draw up the original complaint.

Judge Haight has presided over the Handschu suit for 40 years. He oversaw a settlement in the case in 1985, which laid out guidelines prohibiting any component of the NYPD other than its intelligence division from launching investigations into political activity and requiring that those investigations include evidence of a crime. Eisenstein and his colleagues have served as the suit’s legal guardians since then, reviving the litigation whenever the NYPD fails to follow the guidelines.

Those rules were still in place in 2002, when David Cohen, a former senior CIA officer hired to remake the NYPD’s intelligence division, submitted a document to the court arguing they had become a relic of the past. “In the case of terrorism, to wait for an indication of crime before investigating is to wait for too long,” Cohen wrote.

Acknowledging that the original Handschu rules “addressed different perils in a different time,” Haight agreed to modify the guidelines, eliminating the requirement for specific information indicating a “crime had been or was about to be committed” before launching an investigation, and relaxing rules for deploying undercover officers for intelligence work.

In challenging the fallout from the NYPD’s post-9/11 evolution and Haight’s fateful decision a decade later, the plaintiffs’ attorneys drew evidence from a series of Pulitzer Prize-winning stories published by the Associated Press revealing how the police department sent undercover officers and informants deep into Muslim neighborhoods, mosques, and student groups in and around New York City, where they would record information on who they saw and what they heard.

The AP stories suggested violations of even the loosened Handschu guidelines and provided a crucial foundation for the attorneys challenging the NYPD’s practices. Building on that information, the 2013 Raza suit was eventually folded into the Handschu case, and after much legal wrangling, the two teams of lawyers went to work negotiating a settlement with attorneys for the city and police department.

Announced in January, the resulting settlement included new limits on the length of NYPD investigations involving surveillance of political activity and a first of its kind stipulation that race, religion, or ethnicity should not serve as a driving force in launching such investigations. The agreement also called for the creation of a committee, made up of 11 senior NYPD officials and one civilian representative, that would review intel investigations on a monthly basis.

When the settlement was put to the public this spring, the reception was decidedly mixed. Lawyers for the plaintiffs and their supporters argued that while the settlement was an imperfect compromise, it was a rare opportunity to impose important restrictions on NYPD surveillance. Those opposed to the deal, including Muslim activists and members of the legal community, countered that the agreement was insufficient. In particular, critics argued that the civilian representative lacked authority to truly hold the police department accountable.

As the implications of the settlement were being debated, a report published in August by the Office of the Inspector General for the NYPD called the department’s adherence to its surveillance guidelines further into question. The report examined a random sampling of intelligence division investigations from 2010 to 2015. In addition to finding that more than 95 percent of those investigated were Muslim “or engaged in political activity that those individuals associated with Islam,” the report concluded that “more than half the time, investigations continued even after approval of the operation expired.”

The combination of community involvement in the hearing process and the IG report appear to have made a major impact on the judge, who called for police oversight beyond what the plaintiffs’ lawyers had agreed to.

In his ruling, Judge Haight wrote the “proposed role and powers of the civilian representative do not furnish sufficient protection from potential violations of the constitutional rights of those law-abiding Muslims and believers in Islam who live, move and have their being in this city.” He suggested ways to strengthen the position, including allowing the civilian representative to bring surveillance concerns to the court directly, without having to approach the police commissioner first about perceived infractions.

The judge also quoted heavily from the IG report, making the case that the NYPD’s respect for the Handschu guidelines has become suspect over the years. Referencing the department’s tendency to keep investigations open beyond approved periods, Haight wrote, “Those failures suggest a systemic inclination on the part of the Intelligence Bureau to disregard the guidelines’ mandates.”

Iman Boukadoum, a board member with the Association of Muslim American Lawyers who was active in community conversations regarding the settlement, said Muslim community members deserve credit for making their voices heard throughout the process. “Grassroots groups from mosques to associations were at the forefront of pushing Judge Haight to reconsider the proposed settlement,” Boukadoum told The Intercept.

Haight’s decision is not without its criticisms. Fahd Ahmed, the executive director of DRUM, an organization that works closely with New York City communities impacted by police surveillance, said even with the judge’s recommendations, the ruling does not address shortcomings in key areas.

“The threshold of unverified allegations to start an investigation and send undercovers and informants into communities and organizations is entirely too low,” Ahmed told The Intercept. “Too much manipulation and fabrication can and does take place once that door is opened.”

If opposing sides in the legal fight over the NYPD’s surveillance practices cannot come to a new agreement, the challenge could go to trial.

“The ball is in the NYPD’s court,” Faiza Patel, co-director of the Brennan Center’s Liberty and National Security Program, told The Intercept. “Obviously the plaintiffs are going to be quite happy with these additional protections and so it’s really going to be up to the police department.”