PHILADELPHIA— A federal appeals court on Tuesday reinstated a lawsuit challenging the New York Police Department’s surveillance of Muslim groups in New Jersey after the Sept. 11 terrorist attacks, saying any resulting harm came from the city’s tactics, not the media’s reporting of them.

The 3rd U.S. Circuit Court of Appeals, reversing a judge’s decision last year to dismiss the case, found the Muslim plaintiffs raised sufficient allegations of religious-freedom and equal-protection violations and put the case on track for trial. The court compared the spying to other instances of heightened scrutiny of religious and ethnic groups, including Japanese-Americans during World War II.

In dismissing the lawsuit, U.S. District Judge William Martini had concluded the police could not keep watch “on Muslim terrorist activities without monitoring the Muslim community itself” and concurred with the city in blaming reporting by The Associated Press, which exposed the surveillance program, for any harm.

The appeals court said the attempt to blame the AP was akin to saying, “What you don’t know can’t hurt you. And, if you do know, don’t shoot us. Shoot the messenger.”

The lawsuit revived Tuesday was among legal actions that followed reports by the AP 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. The reporting was honored with a Pulitzer Prize.

Plaintiff Farhaj Hassan said he was “extremely ecstatic” about the court’s decision.

“I’m very happy we will get our day in court,” said Hassan, a U.S. Army sergeant who served in Iraq. “Muslim-Americans were the innocent community in this matter, and lo and behold their civil rights should be protected like everyone else.”

The city called the intelligence gathering an appropriate and legal anti-terrorism tactic and said it never spied on people or businesses solely because they were Muslim. Such a practice would be contrary to its values, a spokesman for the city’s Law Department said.

“There’s been no finding by the court that the NYPD did anything wrong or anything illegal,” said Lawrence Byrne, the NYPD’s deputy commissioner for legal matters. “It’s simply a procedural opportunity for the plaintiffs to see if they can prove their case.”

Former Mayor Michael Bloomberg, former police Commissioner Raymond Kelly and other officials have said the surveillance helped the nation’s largest police department identify and thwart terror plots.