Under pressure from civil liberties advocates and the Muslim community, the San Francisco ­Police Department last month pulled out of the FBI’s Joint ­Terrorism Task Force amid ­controversy over the Trump ­administration’s travel ban and concerns that participation in the task force might violate local laws protecting immigrants and ­religious minorities.

But the move, current and former law enforcement officials said, could weaken efforts to detect and stop terrorist plots in the Bay Area. There are 104 such task forces throughout the country — consisting of cells of analysts, SWAT experts and other specialists from local, state and federal law enforcement agencies that collectively assess intelligence and respond to terrorism threats.

“It’s cutting off your left hand to spite your right hand. It makes no sense at all,” said James McJunkin, a former FBI official who once led the nation’s second-largest Joint Terrorism Task Force, in the nation’s capital. “It thwarts the efforts of hundreds of men and women who go to work every day to fight terrorism.”

[They’re young and lonely. The Islamic State thinks they’ll make perfect terrorists.]

In New York City, for example, the JTTF was critical last September in capturing in less than 40 hours the accused Chelsea bomber, Ahmad Rahimi, who is charged with setting off an explosion that injured 31 people. And task force work led to the 2012 arrest of a Virginia man charged with attempting to blow himself up in the U.S. Capitol.

Civil rights advocates say that municipalities such as San Francisco should not be put in a position of cooperating with federal law enforcement agencies that conduct investigations in a manner that conflicts with local laws and that may share information that leads to noncriminal but ­undocumented immigrants being deported.

“This is a problem not just for San Francisco,” said John Crew, a lawyer formerly with the American Civil Liberties Union who was asked by the SFPD and the FBI to explore solutions to the issue. “It’s a problem around the country of local police assigning officers to the FBI under arrangements that have not been scrutinized in the past, where local civil rights and racial profiling policies are going to be reevaluated in the era of the Trump administration.”

But current and former officials said that the activists’ concern is misplaced.

“The real danger here is you’ve got a singular political issue that is uprooting a well-founded proven benefit to a community,” McJunkin said. “The driving purpose of the JTTF is to spot and assess terrorism threats. Not to go around and gobble up illegal ­immigrants. I’ve never seen an example of that.”

The SFPD said the suspension of cooperation would have happened regardless of who won the presidential election in November, because a 10-year agreement with the JTTF was expiring this month and any renewal requires police commission review.

“We want all persons to feel comfortable in contacting SFPD . . . to report crimes and emergencies without concern as to their immigrations status,” SFPD spokesman Michael Andraychak said. “The city has a history and tradition of demonstrations and other First Amendment activity, and the SFPD works with the community to help facilitate First Amendment activity.”

Officials said they did not think the withdrawal would affect public safety. “We are confident that [local, state and federal law ­enforcement partners] would alert the SFPD to any known ­credible threat against the city,” Andraychak said.

The FBI declined to comment on the issue. But law enforcement officials familiar with the matter said the task forces are not used for noncriminal immigration ­enforcement.

[Stories of refugees and immigrants barred from the U.S.]

San Francisco is the first police department to take such an action this year, but other cities and towns may be following suit. Across the bay in the city of Oakland, the city’s privacy advisory commission on Thursday recommended the City Council approve an ordinance requiring the police force to follow local rules rather than what the commission thinks are less restrictive strict FBI standards in criminal investigations.

Faith-based groups and civil rights advocates are also spearheading efforts to win similar measures in Indiana, Missouri, Florida, Texas, Michigan, New Jersey, New York and Maryland, organizers said.

“We’re asking them to make a commitment to have local police departments commit to being cities where they will reject any information gathering for undocumented immigrants, for political dissenters and religious minorities,” said Michael McBride, director of urban strategies for PICO, a national network of faith-based community organizations.

In Pasadena, Calif., in February, the city manager suspended an agreement between the police department and the Department of Homeland Security’s Immigration and Customs Enforcement (ICE) agency, which authorized joint investigations of human trafficking, drug smuggling and other non-immigration related crimes while the city council considers a resolution declaring Pasadena a sanctuary city. Such a move probably would mean that city police would be barred from asking suspects about their immigration status.

[How sanctuary cities work]

In San Francisco, concerns had been building for some time about the scope of the power the FBI has to investigate people even when there is no reasonable suspicion that they have been involved in crimes, civil liberties advocates said.

In 2015, for instance, a city ­police officer on the JTTF showed up unannounced at Google ­headquarters in Silicon Valley to interview an employee, who was Muslim, about his travels and relatives in Pakistan. The Office of Citizen Complaints found last ­August that the incident was a result of a “training failure” and that it ­violated a police department rule that required that the officer ­document in writing a reasonable suspicion that the target is ­involved in a crime before ­asking questions about First ­Amendment-protected activity.

Advocates also expressed concerns that the JTTF might determine that someone it is interviewing is an undocumented immigrant and that the information may wind up in a database that ICE can use.

A federal law enforcement official, who spoke on the condition of anonymity to discuss a sensitive issue, defended the bureau. Task force officers do not generally seek to interview anyone without reasonable suspicion, he said. “We don’t have the resources or bandwidth to waste our time” going after people without at least some suspicion that they may have knowledge of potential terrorist activity.

He also said that although a task force officer may learn that someone overstayed his visa, if that person is not linked to terrorist activity, the FBI is not likely to pursue a case. “We’re not going to scoop a guy up just for an overstay,” he said.

And an ICE official, who also spoke on the condition of anonymity, said ICE agents on the task force give priority to cases involving significant criminal and terrorism activity, not to visa overstays.

There is precedent for San Francisco’s move. In 2005, Portland, Ore., pulled its police department out of the local JTTF amid concerns that mass interviews of Muslims being conducted by the task force during the Bush administration violated state anti-discrimination laws.

In Los Angeles, which has the nation’s third-largest FBI field office, the police department is not likely to withdraw from the task force, said Deputy Chief Michael Downing, who runs the Los Angeles Police Department’s counterterrorism and special operations bureau.

If major city police departments pull out of the JTTFs, Downing said, “it’s a potential disaster.” Local police have the best connections to the communities they serve, he said, and “the FBI can’t do this by themselves, and major city police departments can’t do this by themselves.”

The San Francisco police spokesman, Andraychak, said a decision to rejoin would be up to the city police commission.

Commission member Bill Hing, a University of San Francisco law professor and expert on immigration law, said he is concerned that the Trump administration “would take full advantage of whatever partnerships they had” with cities to step up deportations.

He said, however, that “public safety is our highest priority.” He expressed faith that the police department can ensure public safety without violating individual rights. “It takes good police work,” he said. “I know it can sometimes be a very fine line.”

This story has been updated.

Read more:

Trump wants to empower local police to enforce immigration law, raising fears of racial profiling

Three words — radical Islamic terrorism — expose a Trump administration divide

What it will take for President Trump to deport millions and build the wall