The New York Police Department’s intelligence unit did not discriminate against Muslims with far-reaching surveillance aimed at identifying “budding terrorist conspiracies” at mosques and other locations in New Jersey, a federal judge has ruled.

In a written decision filed in federal court in Newark, U.S. District Judge William Martini on Thursday dismissed a civil rights lawsuit brought in 2012 by eight Muslims who alleged the NYPD’s surveillance programs were unconstitutional because they focused on religion, national origin and race. The suit had accused the department of spying on ordinary people at several mosques, restaurants and grade schools in New Jersey since 2002.