Those two men, Najibullah Zazi at the mosque and Adis Medunjanin at the school, would go on to be accused of plotting a subway bombing that officials have called the most serious terrorist threat to the United States since Sept. 11, 2001.
Ever since The Associated Press began revealing New York Police Department spying programs on mosques, student groups, Muslim businesses and communities, those activities have been stoutly defended by police and supporters as having foiled a list of planned attacks.
Recently, for instance, when three members of Congress suggested an inquiry into those programs, Republican Rep. Peter King of New York rallied to the NYPD's defense.
"Under Commissioner Ray Kelly's leadership, at least 14 attacks by Islamic terrorists have been prevented by the NYPD," King said.
But a closer review of the cases reveals a more complicated story.
The list cited by King includes plans that may never have existed as well as plots the NYPD had little or no hand in disrupting. According to a review of public documents, materials obtained by the AP and interviews with dozens of city and federal officials, the most controversial NYPD spying programs produced mixed results. The officials interviewed spoke on condition of anonymity because they were not authorized to talk publicly.
There indeed have been successes, such as the 2004 plot uncovered by the NYPD to bomb the Herald Square subway station in Manhattan.
And there have been failures, like Zazi and Medunjanin, who were exactly the kind of people police intended to spot when they developed the spying programs.
And there were other efforts that compiled data on innocent people but produced no meaningful results at all.
Kelly has spent hundreds of millions of dollars transforming the department into one of the nation's most aggressive domestic intelligence agencies. In a city that still hurts from 9/11 and still sees a hole in the ground near where the World Trade Center stood, people have had little interest in questioning whether that effort has been effective. City lawmakers, for instance, learned about many of the department's secretive programs from the AP.
For New Yorkers, the result is that fear of another terrorist attack is used to justify spying on entire neighborhoods. And the absence of another attack is held up as evidence that it works.
Some of the NYPD intelligence programs were born out of fear and desperation. After 9/11, police reached for whatever might work.
One idea was to use informants to trawl local mosques and monitor imams to watch for signs of radicalization. Though the NYPD denies the term exists, several former officials said the informants were known as "mosque crawlers." They would listen in mosques and report back to their handlers.
It was the CIA that first developed that idea overseas and came up with the name. The NYPD program was a version of that effort, according to former CIA officials who were familiar with it. Like many interviewed about the NYPD, they insisted on anonymity because they were not authorized to discuss intelligence programs.
Former senior CIA officials said the mosque crawlers were ineffective.
In New York, however, the program persisted. With help from the mosque crawlers and secret NYPD squads, documents show, police intelligence analysts scrutinized every mosque in and around the city and infiltrated dozens. The monitoring of imams included even those who worked closely with police and preached against violence.
These days, however, fewer imams are under investigation, an official said.
The NYPD has pledged to do all it can to prevent terrorism. So when a new intelligence program is conceived, several current and former officials said, there is little discussion of its prospects for success.
NYPD intelligence chief David Cohen, a former top CIA official, was asked about that in September 2005 during a deposition in a lawsuit over the department's policy of randomly searching the bags of subway riders. Civil rights lawyers asked how police knew whether a program deterred terrorism.
"If it works against them, then it works for us," Cohen replied. "That is deterrent to one degree or other."
Cohen was asked, How do you know it works? Is there some police methodology?
"I never bothered to look," Cohen said. "It doesn't exist, as far as I could tell."
At times, police officials themselves have raised concerns about intelligence-gathering programs. In about 2008, for instance, police began monitoring everyone in the city who legally changed names. Anyone who might be a Muslim convert or appeared to be Americanizing his or her name was investigated and personal information was put into police databases.
Current and former officials say it produced no results. Police still receive the list of names of people who change their names, court officials said. But one official said the program is on hold while its effectiveness is evaluated.
Kelly has said the NYPD does not trawl neighborhoods and instead only pursues leads. But those leads can be ambiguous, officials say, and can be used to justify widespread surveillance programs.
For example, the NYPD began the "Moroccan Initiative," a secret program that chronicled Moroccan neighborhoods, after suicide bombings killed 45 people in the Moroccan city of Casablanca in 2003, and after Moroccan terrorists were linked to the 2005 train bombing in Madrid. New York police put people, including U.S. citizens, under surveillance and catalogued where they ate, worked and prayed.
"What we were doing is following leads," Kelly told City Council members during an October hearing when asked about that program. "The Moroccan issue that was mentioned had to do with a specific investigation."
But officials involved in the program said there was no specific threat to New York from Moroccans. The Moroccan Initiative thwarted no plots and led to no arrests, officials said.
Much of the information in the Moroccan Initiative was gathered by a secretive squad known as the Demographics Unit. Using plainclothes officers known as "rakers," the squad infiltrated local businesses and community organizations looking for trouble or "hot spots." Their daily reports helped create searchable databases of life in New York's Muslim neighborhoods.
One NYPD official said that unit identified a Brooklyn bookstore as a hot spot. That led police to open an investigation and send in an informant and undercover detective, ultimately leading to the arrests of two men in the Herald Square case.
The work of that secret unit, the official said, helped the NYPD arrest a Pakistani immigrant named Shahawar Matin Siraj and foiled an attack.
For years, police have said publicly that the Herald Square case began with a tip but have not elaborated. Siraj's lawyer, Martin Stolar, said prosecutors provided no documents related to the Demographics Unit at trial.
Siraj was convicted and sentenced to 30 years in federal prison in 2007. But defense attorneys, and even some inside the NYPD intelligence unit, said police had coaxed the men into making incriminating statements and there was no proof Siraj ever obtained explosives.
The case is arguably the NYPD's greatest counterterrorism success. But there are others.
The NYPD played an important role in the case against Carlos Amonte and Mohammed Alessa, two New Jersey men who pleaded guilty to charges they tried to leave the country in 2010 to join the al-Qaida-linked terrorist group al-Shabaab. The FBI long had been aware of the two men but had been unable to win their trust with an informant or undercover agent, federal officials said. The NYPD, with its deep roster of Muslim officers, provided the undercover officer who ultimately succeeded in winning their confidence.
When the NYPD's effectiveness is questioned, the department's most ardent supporters frequently point to a long list of terrorist plots said to have targeted New York since 9/11. The list often is described as plots thwarted by the NYPD.
"One can't argue with results," said Peter Vallone, the New York city councilman who heads the Public Safety Committee. "The results of this gargantuan effort have been that at least 13 planned attacks on New York City have been prevented."
In reality, however, the NYPD played little or no role in preventing many of those attacks.
Some, like a cyanide plot against the subway system, were discovered among evidence obtained overseas but were never set into motion. Others, like the 2006 plot to blow up U.S.-bound airliners using liquid explosives, were thwarted by U.S. and international authorities, and plans never got off the ground.
And some, like the 2008 subway plot, went unnoticed by the NYPD despite the money and manpower devoted to monitoring Muslim communities, according to the NYPD files obtained by the AP. The files along with interviews show the NYPD was monitoring Zazi's mosque, and also the Muslim student organization Medunjanin attended. Zazi and Medunjanin were friends and had been praying together regularly since 9th grade. As the years passed, Zazi grew increasingly upset about civilians killed by the U.S. military in Afghanistan; Medunjanin was outraged by the way Muslims were treated at Iraq's Abu Ghraib prison, and he promoted jihad at the mosque and after basketball games with friends, according to court documents. He said his friends didn't have the "balls" to do anything.
The plot was discovered after U.S. intelligence intercepted an email revealing that Zazi was trying to make a bomb.
Those programs, meanwhile, have widened the chasm between the police and the city's Muslims, a community the Obama administration says is a crucial partner in the effort to prevent another terrorist attack. Fed up with a decade of being under scrutiny, some Muslim groups now urge against going directly to police when someone hears radical, anti-American talk.
They reason that the person is probably a police informant.
Each morning at the NYPD, Cohen meets his senior officers to discuss the latest intelligence before he briefs Kelly. There is no bigger target for terrorists than New York, the nation's largest city and the heart of the financial and media world. Cohen repeatedly reminds his officers that, on any given day, they might be the only thing standing in the way of disaster. It's a mentality that officials say underscores the seriousness of the threat and the NYPD's commitment to the effort.
Several current and former officials point to that pressure to explain why programs rarely get scrapped, even when there are doubts about their effectiveness. Nobody wants to be the one to abandon a program, only to witness a successful attack that it might have prevented.
At the federal level, intelligence programs are reviewed by Congress, inspectors general and other watchdogs. The NYPD faces no such scrutiny from the City Council or city auditors. Federal officials, too, have been reluctant to question the effectiveness of the NYPD, despite spending more than $1.6 billion in federal money on the department since 9/11.
After House Democrats circulated a letter signed by 34 members of Congress recently asking for a federal review of the NYPD's intelligence programs, King, the New York Republican, accused them of smearing the police department.
The Justice Department under Eric Holder repeatedly has sidestepped questions about what it thinks about the NYPD programs revealed by the AP. Some Democrats in Congress have asked prosecutors to investigate. Since August, the department has said only that it is reviewing those requests.
During the Bush administration, Attorney General Alberto Gonzales and senior Justice Department officials received a briefing in New York about the NYPD's capabilities, according to a former federal official who attended.
Gonzales left convinced, the official said, that the federal government could not replicate those programs. The NYPD had more manpower and operated under different rules than the federal government, the Justice Department concluded. And the mayor had accepted the political risk that came with the programs.
It was a policy briefing only, the former official said, meaning the federal government did not review the NYPD programs to determine whether they were lawful.
The NYPD's terrorist cases include ones the federal government has declined to prosecute. Last year, a grand jury declined to indict Ahmed Ferhani and Mohamed Mamdouh on the most serious charge initially brought against them, a high-level terror conspiracy count that carried the potential for life in prison without parole. They were indicted on lesser state terrorism and hate crime charges, including one punishable by up to 32 years behind bars.
Last month, NYPD detectives arrested Jose Pimentel on terrorism-related charges. A state grand jury has yet to indict him on those charges. Federal and city law enforcement officials who reviewed the case told the AP there were concerns that Pimentel lacked the mental capacity to act on his own. The NYPD informant's drug use in the case also created serious issues, the officials said.
FBI Director Robert Mueller has tried to mute criticisms of the NYPD. On a visit to the Newark, N.J., FBI office a few years ago, current and former officials recall, agents asked Mueller how the NYPD was allowed to operate undercover in the state, with no FBI coordination. Mueller replied that it was a reality the bureau would have to live with, the officials said.
There will always be some debate over the effectiveness of intelligence-gathering programs, particularly ones that butt up against civil liberties. Nearly a decade after the last terrorist suspect was waterboarded in a secret CIA prison in 2003, for instance, politicians and experts still debate whether the tactic gleaned valuable information and whether it could have been obtained without such harsh methods.
During the Bush administration, officials repeatedly pointed to the years without a successful terrorist attack to justify the most contentious programs from the war on terrorism. Vice President Dick Cheney used the years without an attack to defend the secret National Security Agency wiretapping program. Gonzales credited the USA Patriot Act and military actions abroad. And President George W. Bush said the years without an attack validated his polices.
"While there's room for honest and healthy debate about the decisions I've made - and there's plenty of debate," Bush said in the final days of his presidency, "there can be no debate about the results in keeping America safe."
When questioned about its own programs, the NYPD has made the same arguments.
During the 2005 deposition over the subway searches, lawyers pressed Cohen to explain how the NYPD could be so sure its programs really worked.
"They haven't attacked us," he said.
Contact the Washington investigative team at DCInvestigations(at)ap.org
Follow Apuzzo, Goldman and Sullivan at http://twitter.com/mattapuzzo and http://twitter.com/goldmandc and http://twitter.com/esullivanap