NEW YORK — The city has reached the outlines of a settlement with Muslims who challenged police surveillance as an unconstitutional and stigmatizing intrusion on their religious rights, a court filing says.

City lawyers said in a letter filed Friday that there's a "settlement in principle" in a lawsuit filed by mosques, a charity and community leaders. The plaintiffs sued in 2013, saying the New York Police Department's post-Sept. 11 intelligence-gathering tarnished law-abiding Muslims.

Some details of the potential pact remain unresolved, according to the letter, which says the terms can't be disclosed because of a confidentiality order. The city Law Department, the American Civil Liberties Union and the New York Civil Liberties Union declined to comment Monday on the potential settlement.

The ACLU and the NYCLU are among the plaintiffs' lawyers in the Brooklyn federal case. The lawsuit was among legal actions that followed reports by The Associated Press that revealed how city police infiltrated Muslim student groups, put informants in mosques and otherwise spied on Muslims as part of a broad effort to prevent terrorist attacks.

A similar lawsuit is before a federal appeals court in Philadelphia after a New Jersey federal judge threw it out.

READ MORE: Muslim population to pull close to Christians worldwide by 2050, survey says

The city has called the intelligence-gathering an appropriate and legal anti-terrorism tactic. Although a senior NYPD official testified in 2012 that the Demographics Unit at the heart of the program never generated any leads or triggered a terrorism investigation, former Mayor Michael Bloomberg, former police Commissioner Raymond Kelly and other officials said the surveillance helped the nation's largest police department identify and thwart terror plots.

"Police need to be informed about where a terrorist may go while planning or what they may do after an attack," city lawyer Celeste Koeleveld said when the suit was filed.

But the plaintiffs said the spying painted Muslim communities with unwarranted suspicion. A charity said fundraising declined because it had been targeted. An imam said attendance declined at his mosque and people were reluctant to speak to newcomers because they feared spies.

"Our mosque should be an open, religious and spiritual sanctuary, but NYPD spying has turned it into a place of suspicion and censorship," said the imam, Hamid Hassan Raza.

The lawsuit asked a judge to order the NYPD to stop the surveillance and destroy any related records. The plaintiffs also sought a court-appointed monitor to ensure the police department follows the law.

In the meantime, current police Commissioner William Bratton disbanded the Demographics Unit last year, reassigning its detectives. Democratic Mayor Bill de Blasio called the move "a critical step forward in easing tensions between the police and the communities they serve, so that our cops and our citizens can help one another go after the real bad guys."

The potential settlement was first reported by the Daily News.

Associated Press writer Jake Pearson contributed to this report.

Related Links:

Supreme Court rules for Muslim prisoner and religious freedom

‘Radical Muslims’ clothing line attempts to shatter stereotypes

New online miniseries is 'The Cosby Show' for Muslim-Americans