In the aftermath of the al-Qaeda attacks on New York and Washington, authorities launched a widespread surveillance programme that targeted Muslims in New York City and New Jersey.

It was halted ollowing several lawsuits, and an historic legal settlement in which the nation’s largest police force agreed not to conduct surveillance operations based on religion or ethnicity.

In an interview with PBS, Mr Bloomberg, 78, a billionaire businessman contesting for the Democratic presidential nomination and who served three terms as mayor of New York from 2002 to 2013, he defended his actions.

Asked about the allegedly illegal operation, the extent of which was revealed in a a series of investigative articles published by the Associated Press in 2011, Mr Bloomberg, said: “We sent some officers into some mosques to listen to the sermon that the imam gave. The courts ruled it was exactly within the law and that’s the kind of thing we should be doing.”

Democratic candidates compete on the campaign trail: In pictures Show all 18 1 /18 Democratic candidates compete on the campaign trail: In pictures Democratic candidates compete on the campaign trail: In pictures Jessica Canicosa, a precinct captain for Bernie Sanders, waits to greet caucus voters at Liberty High School in Henderson, Nevada REUTERS Democratic candidates compete on the campaign trail: In pictures Hotel workers at the Bellagio in Las Vegas get to grips with voting papers during the Nevada caucuses AFP via Getty Images Democratic candidates compete on the campaign trail: In pictures A caricature of Bernie Sanders is projected on to a tree during a rally in Las Vegas EPA Democratic candidates compete on the campaign trail: In pictures A woman waits to have a photo taken with Elizabeth Warren during a town hall meeting in Las Vegas REUTERS Democratic candidates compete on the campaign trail: In pictures The threat of coronavirus and other germ-borne illnesses was on some voters' minds at the Democratic caucuses in Henderson, Nevada Getty Images Democratic candidates compete on the campaign trail: In pictures Former vice-president Joe Biden takes a selfie with a voter in Las Vegas ahead of the Nevada caucuses REUTERS Democratic candidates compete on the campaign trail: In pictures Amy Klobuchar changes her shoes backstage after giving a speech in Exeter, New Hampshire AFP/Getty Democratic candidates compete on the campaign trail: In pictures A warmly-wrapped-up dog attends an Elizabeth Warren event at Amherst Elementary School in Nashua, New Hampshire AFP/Getty Democratic candidates compete on the campaign trail: In pictures Bernie Sanders, who romped to victory in New Hampshire against Hillary Clinton in 2016, talks to the media in Manchester Getty Democratic candidates compete on the campaign trail: In pictures Joe Biden was hoping to improve on his poor showing in Iowa in the New Hampshire primary Reuters Democratic candidates compete on the campaign trail: In pictures Elizabeth Warren, renowned for giving time to supporters for selfies, works the crowd at the University of New Hampshire in Durham Getty Democratic candidates compete on the campaign trail: In pictures Joe Biden takes a selfie with a supporter and his child outside a campaign event in Somersworth, New Hampshire on 5 February Reuters Democratic candidates compete on the campaign trail: In pictures Elizabeth Warren and Bernie Sanders quarrel after a confrontation in a TV debate in which Sanders claimed that Warren was not telling the truth about a conversation in which she claimed he had said a woman could not win the presidency on 14 January AP Democratic candidates compete on the campaign trail: In pictures Supporter Pat Provencher listens to Pete Buttigieg in Laconia, New Hampshire on 4 February Getty Democratic candidates compete on the campaign trail: In pictures Pete Buttigieg speaks at a campaign event in Concord, New Hampshire while awaiting the results of the Iowa caucus Reuters Democratic candidates compete on the campaign trail: In pictures Elizabeth Warren is presented with a balloon effigy of herself at a campaign event in Nashua, New Hampshire on 5 February Reuters Democratic candidates compete on the campaign trail: In pictures A Trump supporter rides past a rally for Amy Klobuchar in Des Moines, Iowa on 14 January AP Democratic candidates compete on the campaign trail: In pictures A man holds up a sign criticising billionaires in the presidential race in front of Michael Bloomberg in Compton, Califronia. The former New York mayor skipped the first caucus in Iowa and instead campaigned in California on 3 February Reuters

He added: “All of the people came from the same place and all that came were from a place they happened to be one religion. And if they’d been another religion, we would’ve done the same thing.

“It does not, incidentally, mean that all Muslims are terrorists or all terrorists are Muslim. But, the people that flew those airplanes came from the Middle East and some of the imams were urging more of the same.”

Activists have denounced the comments of the former mayor, who was recently obliged to apologise for another controversial policing policy – so-called stop and frisk – that he promoted.

AOC discusses Mike Bloomberg running for president in 2020

“The idea that the NYPD surveilled Muslims in just a few mosques with court approval is a fantasy,” said Farhana Khera, executive director of the group Muslim Advocates.

“In reality, the NYPD filmed, tracked and monitored Muslims in mosques, restaurants, schools and more with cameras and undercover officers—all without their knowledge, in New York and New Jersey.”

She added: “A federal appeals court, in a unanimous decision, harshly rebuked this programme in a landmark ruling, likening it to the treatment of Jewish-Americans during the “red scare”, African-Americans during the civil rights movement, and Japanese-Americans during World War II.”

Following the series of articles by the AP, activists filed what has come to be known as as Hassan v City of New York, that accused the police department of unconstitutional behaviour. In 2018, the city agreed to stop the programme, pay $75,000 in damages and $1m in legal fees. It also agreed to meet with members of the Muslim community to discuss issues.

The former mayor’s remarks come just a day before the South Carolina primary, where his name is not on the ballot, and Super Tuesday, when people in more than a dozen states will cast their votes.