The operations have benefited from unprecedented help from the CIA, a partnership that has blurred the line between foreign and domestic spying.
The department has dispatched undercover officers, known as "rakers," into minority neighborhoods as part of a human mapping program, according to officials directly involved in the program.
They've monitored daily life in bookstores, bars, cafes and nightclubs. Police have also used informants, known as "mosque crawlers," to monitor sermons, even when there's no evidence of wrongdoing.
Neither the city council, which finances the department, nor the federal government, which has given NYPD more than $1.6 billion since 9/11, is told exactly what's going on.
Many of these operations were built with help from the CIA, which is prohibited from spying on Americans but was instrumental in transforming the NYPD's intelligence unit.
A veteran CIA officer, while still on the agency's payroll, was the architect of the NYPD's intelligence programs. The CIA trained a police detective at the Farm, the agency's spy school in Virginia, then returned him to New York, where he put his new espionage skills to work inside the United States.
And just last month, the CIA sent a senior officer to work as a clandestine operative inside police headquarters.
The NYPD denied that it trolls ethnic neighborhoods and said it only follows leads. Police operations have disrupted terrorist plots and put several would-be killers in prison.
"The New York Police Department is doing everything it can to make sure there's not another 9/11 here and that more innocent New Yorkers are not killed by terrorists," NYPD spokesman Paul Browne said. "And we have nothing to apologize for in that regard." AP's investigation is based on documents and interviews with more than 40 current and former New York Police Department and federal officials. Many were directly involved in planning and carrying out these secret operations for the department. Though most said the tactics were appropriate and made the city safer, many insisted on anonymity, because they were not authorized to speak with reporters about security matters.
In response to the story, the Council on American-Islamic Relations, a leading Muslim civil rights organization, called on the Justice Department to investigate. The Justice Department had no immediate comment.
"This is potentially illegal what they're doing," said Gadeir Abbas, a staff attorney with the organization.
After the terrorist attacks, New York hired retired CIA official David Cohen to transform its intelligence division.
Among Cohen's earliest moves at the NYPD was asking for help from his old CIA colleagues. He needed someone who had access to the latest intelligence so the NYPD wouldn't have to rely on the FBI to dole out information.
CIA Director George Tenet dispatched Larry Sanchez, a respected CIA veteran, to New York while Sanchez was still on the CIA payroll, three former intelligence officials said. Sanchez directed and mentored officers, schooling them in the art of gathering information, officials said.
There had never been an arrangement like it, and some senior CIA officials soon began questioning whether Tenet was allowing Sanchez to operate on both sides of the wall that's supposed to keep the CIA out of the domestic intelligence business.
"It should not be a surprise to anyone that, after 9/11, the Central Intelligence Agency stepped up its cooperation with law enforcement on counterterrorism issues or that some of that increased cooperation was in New York, the site of ground zero," CIA spokeswoman Jennifer Youngblood said.
Cohen also persuaded a federal judge to loosen rules and allow police to open investigations before there's any indication a crime has been committed.
With that newfound authority, Cohen created a secret squad that would soon infiltrate Muslim neighborhoods, according to several current and former officials directly involved in the program.
The NYPD assigned undercover officers to monitor neighborhoods, looking for potential trouble. Using census data, police matched undercover officers to ethnic communities and instructed them to blend in, the officials said. They hung out in hookah bars and cafes, quietly observing the community around them.
The unit, which has been undisclosed until now, became known inside the department as the Demographic Unit, former police officials said.
"It's not a question of profiling. It's a question of going where the problem could arise," said Mordecai Dzikansky, a retired NYPD intelligence officer who said he was aware of the Demographic Unit. "And thank God we have the capability. We have the language capability and the ethnic officers. That's our hidden weapon."
Cohen said he wanted the squad to "rake the coals, looking for hot spots," former officials recalled. The undercover officers soon became known inside the department as rakers.
For years, detectives also used informants known as mosque crawlers to monitor weekly sermons and report what was said, several current and former officials directly involved in the informant program said. If FBI agents were to do that, they would be in violation of the Privacy Act, which prohibits the federal government from collecting intelligence on purely First Amendment activities.
Browne, the NYPD spokesman, flatly denied the accounts of mosque crawlers and rakers. He said the NYPD only uses undercover officers and informants to follow leads, not to target ethnic neighborhoods.
"We will go into a location, whether it's a mosque or a bookstore, if the lead warrants it, and at least establish whether there's something that requires more attention," Browne said.
Last month, the CIA deepened its ties to the NYPD. It sent one of its most senior spies to New York to work out of police headquarters, on the CIA payroll. He is a special assistant in the intelligence division but U.S. officials said he is not doing intelligence-gathering. His name remains classified.
"It's like starting the CIA over in the post-9/11 world," Cohen said in "Protecting the City," a laudatory 2009 book about the NYPD. "What would you do if you could begin it all over again? Hah. This is what you would do."
Associated Press writers Tom Hays and Eileen Sullivan in Washington contributed to this report.