When a Danish newspaper published inflammatory cartoons of Prophet Muhammad in September 2005, Muslim communities around the world erupted in outrage. Violent mobs took to the streets in the Middle East. A Somali man even broke into the cartoonist's house in Denmark with an ax.

In New York, thousands of miles (kilometers) away, it was a different story. At the Masjid Al-Falah in Queens, one leader condemned the cartoons but said Muslims should not to resort to violence. Speaking at the Masjid Dawudi mosque in Brooklyn, another called on Muslims to speak out against the cartoons, but peacefully.

The sermons, all protected under the First Amendment to the Constitution, were reported back to the NYPD by the department's network of mosque informants. They were compiled in police intelligence reports and summarized for Police Commissioner Raymond Kelly.

Those documents offer the first glimpse of what the NYPD's informants — known informally as "mosque crawlers" — gleaned from inside the houses of worship. And, along with hundreds of pages of other secret NYPD documents obtained by The Associated Press, they show police targeting mosques and their congregations with tactics normally reserved for criminal organizations.

They did so in ways that brushed against — and civil rights lawyers say at times violated — a federal court order restricting how police can gather intelligence.

The NYPD Intelligence Division snapped pictures and collected license plate numbers of congregants as they arrived to pray. Police mounted cameras on light poles and aimed them at mosques. Plainclothes detectives mapped and photographed mosques and listed the ethnic makeup of those who prayed there.

"It seems horrible to me that the NYPD is treating an entire religious community as potential terrorists," said civil rights lawyer Jethro Einstein, who reviewed some of the documents and is involved in a decades-old, class-action lawsuit against the police department for spying on protesters and political dissidents.

The documents provide a fuller picture of the NYPD's unapologetic approach to protecting the city from terrorism.

Kelly, the police commissioner, has said the NYPD complies with its legal obligations, according to statements he made in October during a rare City Council oversight hearing about the NYPD surveillance of Muslims.

The AP has reported for months that the NYPD infiltrated mosques, eavesdropped in cafes and monitored Muslim neighborhoods. New Muslim converts who took Arabic names were compiled in police databases.

Recently, the NYPD has come under fire for its tactics.

— Universities including Yale and Columbia have criticized the department for infiltrating Muslim student groups and trawling their websites. Police put the names of students and academics in reports even when they were not suspected of wrongdoing.

— In Newark, New Jersey, Mayor Cory Booker said he was offended by the NYPD's secret surveillance of his city's Muslims.

NYPD spokesman Paul Browne did not respond to an email seeking comment. Browne has previously denied the NYPD used mosque crawlers or that there was a secret Demographics Unit that monitored daily life in Muslim communities.

The NYPD spying operations began after the 2001 terror attacks against the World Trade Center and the Pentagon, with unusual help from a CIA officer.

The agency's inspector general recently found that relationship problematic but said no laws were broken. Shortly after that report, the CIA decided to cut short the yearlong tour of an operative who was recently assigned to the NYPD.

Kelly, the police commissioner, and Mayor Michael Bloomberg have been emphatic that police only follow legitimate leads of criminal activity and do not conduct preventive surveillance in ethnic communities.v

"If there are threats or leads to follow, then the NYPD's job is to do it," Bloomberg said last year. "The law is pretty clear about what's the requirement, and I think they follow the law. We don't stop to think about the religion. We stop to think about the threats and focus our efforts there."

Officials say that David Cohen, the deputy commissioner for intelligence, was at the center of the efforts to spy on the mosques.

"Take a big net, throw it out, catch as many fish as you can and see what we get," one investigator recalled Cohen saying.

vCohen wanted a source inside every mosque within a 250-mile (400-kilometer) radius of New York, current and former officials said. Though the officials said they never managed to reach that goal, documents show the NYPD successfully placed informants or undercovers — sometimes both — into mosques from Westchester County, New York, to New Jersey.

The NYPD used these sources to get a sense of the sentiment of worshippers whenever an event generated headlines. The goal, former officials said, was to alert police to potential problems before they bubbled up.

Copyright 2012 The Associated Press.