NEW YORK -- The New York Police Department will strengthen safeguards against illegal surveillance of Muslims in terrorism investigations and install a civilian representative on a committee that reviews the investigations under the terms of a settlement of two high-profile civil rights lawsuits, lawyers said Thursday.

The announcement of the deal formally ended litigation over accusations that the nation's largest police department was illegally infiltrating mosques and spying on Muslims based on their religion.

"We are committed to strengthening the relationship between our administration and communities of faith so that residents of every background feel respected and protected," Mayor Bill de Blasio said in a statement.

Get Breaking News Delivered to Your Inbox

The settlement modifies and adds restrictions on surveillance set by the court-ordered Handschu decree, which was put in place in response to surveillance used against war protesters in the 1960s and '70s. The decree was relaxed following the Sept. 11, 2001, terror attacks to allow police to more freely monitor political activity in public places.

Civil rights groups sued in 2013, accusing the NYPD of breaking Handschu rules. A second suit filed that year by mosques, a charity and community leaders alleged that the department was discriminating against Muslims.

Under the deal, the Handschu guidelines will specifically ban investigations based on race, religion or ethnicity. The civilian representative will attend monthly meetings that review the investigations and have authority to report any civil rights concerns to the mayor or the court.

Police officials said the settlement formalizes safeguards that were already in place, and it doesn't require the NYPD to admit any wrongdoing.

A predominantly Muslim community in Paterson, New Jersey was one of the areas under police surveillance after 9/11. New York Police Department officers monitored mosques, businesses and schools in what the department said was an effort to root out potential terrorists.

Syed Farhaj Hassan, an Army reservist who served in Iraq for more than a year, told CBS News last year that his mosque was targeted and that made him stop going.

"The American Muslim community was victimized by the New York Police Department and their warrant-less surveillance," Hassan said. "There's no reason that that should stand to continue."

The NYPD demographics unit which conducted the surveillance was shut down in 2014.