Police in the US city of Boston unjustly spied on thousands of social media posts and specifically targeted Muslims and African Americans for surveillance, a new report by the American Civil Liberties Union (ACLU) has alleged.

The Boston Police Department (BPD) used an online surveillance system, Geofeedia, from 2014 to 2016 to monitor online comments on topics including politics and religion, the ACLU of Massachusetts said on Wednesday.

"The BPD treated ordinary citizens discussing ordinary affairs as justifiable targets of surveillance," the group said in a statement.

"What it did not do … was deter or help solve serious crimes."

The civil rights organisation said the BPD unfairly focused its surveillance on African Americans and Muslims by creating online alerts for the use of innocuous Arabic words and the hashtags #BlackLivesMatter and #MuslimLivesMatter.

Activists have used the hashtag #BlackLivesMatter to denounce police brutality targeting African-Americans.

#MuslimLivesMatter was used to draw attention to Islamophobia after three Muslim students were killed in a shooting in North Carolina in 2015.

Lack of transparency

Based on documents obtained through a public records request, the ACLU report said police treated people as suspicious on the basis of their race, religion and ethnicity.

"The records demonstrate the clear need for both transparency and procedural safeguards to ensure that this type of software is subject to public scrutiny and ongoing oversight before it is used again," the group said.

For its part, the BPD has accused the ACLU of reaching misguided conclusions.

It said its surveillance programme helped police monitor events and demonstrations which had the potential to turn violent.

"Our main focus in all of this is public safety, not targeting speech, not targeting people's political affiliations,'' Lieutenant Detective Michael McCarthy told reporters on Wednesday.

"Quite frankly, to have the ACLU even make that insinuation is not only insulting, it's completely misinformed."

The ACLU has called on the BPD to change its privacy policies in the wake of the report, however.

The group said surveillance based on race, religion or ethnicity should be outlawed, except in cases where law enforcement officials have reasonable grounds to believe an individual has broken the law.

In early 2017, the BPD withdrew a $1.4m funding request for a new social media surveillance system following widespread opposition from civil rights groups.