The Central Intelligence Agency is launching an investigation into whether CIA agents broke the law by helping New York police officers monitor minorities and cultivate informants in Muslim communities.

Recently installed CIA director David Petraeus said that the inquiry began at the behest of his predecessor, acting director Michael Morell. Petraeus confirmed at a Congressional hearing Tuesday that the CIA had an adviser at the New York police department and said that the CIA wanted to make sure we are doing the right thing.

An Associated Press investigation exposed how the CIA helped the NYPD to drastically expand its surveillance and intelligence gathering activities, with police officers dispatched to monitor ethnic neighborhoods earning the informal nickname of the Demographic Unit.

Some of the NYPD's activities, including sending informants and undercover agents to mosques without any specific evidence of criminal activity, may have broken the law, according to sources interviewed by The Associated Press.

If you're sending an informant into a mosque when there is no evidence of wrongdoing, that's a very high-risk thing to do, FBI general counsel Valerie Caproni told the AP. You're running right up against core constitutional rights. You're talking about freedom of religion.