Former New York Mayor Mike Bloomberg is defending the controversial New York Police Department surveillance program which placed undercover officers at mosques and other places Muslims frequent in the city

“We had just lost 3,000 people at 9/11," Bloomberg said in an interview Thursday with PBS NewsHour's Judy Woodruff adding that he felt the NYPD acted well within the confines of the law.

"Of course we were supposed to do that,” he said.

His comments received swift backlash from civil liberties advocates who said the program eroded trust between those communities and law enforcement and sewed seeds of mistrust within communities through surveillance seen as profiling.

The surveillance program was established in the aftermath of the deadly September 11th attacks which were coordinated by the terrorist group al Qaeda. The NYPD said the effort was aimed at staving off future attacks.

The program's efforts ultimately resulted in a settlement aimed at curbing surveillance overreach against citizens.

The ACLU responded by saying that Bloomberg's comments were an attempt to rewrite history.

"This is an insulting attempt to rewrite the history of an unconstitutional surveillance program that left Muslims, particularly in communities of color, devastated," Hina Shamsi, director of the ACLU's National Security Project said in a statement. "The facts are that the police and city leaders who were supposed to equally protect all our communities instead betrayed them. It took brave Muslims and their supporters to go to court before the NYPD finally agreed to reforms to safeguard communities in New York and beyond."

The ACLU also noted that no court had ever found the surveillance program under Bloomberg to be, "lawful."

Asked specifically if he thought it was necessary to single out Muslims Americans, Bloomberg said the NYPD also looked elsewhere and followed the intelligence they had at the time. He added that there was “no question” about where the attackers came from before quickly noting that he had spoken in favor of the construction of a mosque in New York City and that he’s a “believer of freedom of religion.”

“We've put an enormous amount of work in coordinating with federal intelligence agencies and state intelligence agencies to try to keep this country safe, and there's no question about whether the people who committed the terrible atrocities of the three airplane crashes and all the people getting killed, where they came from and it's a natural place to go, yes.

"But, remember, I was the one who defended building a mosque in New York City, which I got grief for, but I'm a believer of freedom of religion, but we've continued to this day, I assume, to keep our eyes and ears open and look wherever you can legally to make sure nothing like that is going to happen again,” he said.

Bloomberg wouldn’t answer when asked if he thought it was okay to target Muslim Americans, but said it is “okay to go where you think there might be information.” After noting that not “all Muslims are terrorists or all terrorists are Muslim,” Bloomberg said they were targeting imams who officers claimed were reportedly “stirring things up.”

“No, it's okay to go where you think there might be information that would be useful in keeping us safe, and there were imams who publicly at that time were urging terrorism, so, of course, that's where you're going to go," he said. "It does not, incidentally, mean all Muslims are terrorists or all terrorists are Muslim, but there was -- the people that flew those airplanes came from the Middle East and some of the imams were urging more of the same and, of course, we sent the police officers in, and we were so super careful because you knew people would look at it, and I didn't want anybody to think we were targeting an ethnicity."

Woodruff responded that a religion didn’t kill the victims of 9/11.

“No but all people came from the same place and all that came were from a place that happened to be one religion,” he said. “If they had been another religion, we would have done the same thing.”

Asad Dandia, who was befriended by an NYPD informant as a teen as part of the surveillance program told ABC News that he was initially contacted under the premise of “wanting to become a better Muslim.” Dandia ran an organization called Muslims Giving Back and the informant participated in some of its events and joined his group of friends.

Dandia eventually joined the lawsuit against NYPD that brought about policy changes which included prohibiting investigations in which religion, race, or ethnicity are a motivator.

“It was appalling — though unsurprising — to see Michael Bloomberg double down on defending the NYPD’s discriminatory surveillance of Muslim communities," Dandia said in a statement and added that he feels Bloomberg has shown "a complete lack of remorse for the emotional damage he has caused to Muslims in the New York metro area."

"Those of us who came of age under Bloomberg’s discriminatory policies in New York — Muslim, Latinx, Black, and poor — know the harm that this man is capable of," Dandia said. "He is quite frankly unsuitable to be president.“