In a decision filed today in federal court in Newark, US District Judge William Martini dismissed a lawsuit brought in 2012 by eight Muslims who alleged that the NYPD's surveillance programs were unconstitutional because they focused on religion, national origin and race.
The suit accused the department of spying on ordinary people at mosques, restaurants and schools in New Jersey since 2002.
The lawsuit followed a series of stories by The Associated Press based on confidential NYPD documents that showed how the department sought to infiltrate dozens of mosques and Muslim student groups in New York and elsewhere.
The judge added: "The police could not have monitored New Jersey for Muslim terrorist activities without monitoring the Muslim community itself."
Farhaj Hassan, a plaintiff in the case and a US soldier who served in Iraq, said he was disappointed by the ruling.
"I have dedicated my career to serving my country, and this just feels like a slap in the face, all because of the way I pray," he said.