Updated

The jihadist attacks in Barcelona and Cambrils in mid-August, which killed a dozen people and injured 120 more, might have been prevented, except for the dysfunctional relationship between Spain’s central government in Madrid and the leaders of the separatist movement in Catalonia, the autonomous region of which Barcelona is the capital.

Indeed, the attack highlights the dangers of the politicization of security policy and can serve as a warning to the U.S., home to an estimated 300 sanctuary cities, counties and states that are potential safe havens for violent extremists from abroad.

How so? The investigation into the Spanish attacks has highlighted a breakdown in communication and coordination between the National Police and the Civil Guard, which are controlled by Madrid, and the Catalan autonomous police, known as the Mossos d’Esquadra.

The central government has been accused of withholding actionable information about members of the Barcelona terror cell. The Mossos have been accused of seeking to showcase Catalonia’s “self-sufficiency” in security matters ahead of an October 1 vote for independence from Spain, and as a result failing to take adequate measures to keep track of the jihadist threat.

In an effort to promote Catalan nationalism and the Catalan language, Catalonian pro-independence parties have deliberately encouraged immigration from Muslim countries in the belief that these immigrants (unlike those from Latin America) would learn the Catalan language rather than Spanish.

This may explain how a 12-member terror cell was able to prepare the attack for more than half a year without detection by Spanish authorities at the central, regional and local levels.

Only now is Spain slowly waking up to that possibility. “The total absence of police collaboration between the Mossos d’Esquadra, which is the police force deployed on the ground, and the National Police and the Civil Guard translates into huge security deficiencies,” warned El Periódico de Catalunya, a newspaper based in Barcelona.

“The relationship between police forces — influenced by the political situation — is terrible and, in the case of the Mossos and the National Police, it is open war,” the newspaper added.

“The result is that the information services of the Mossos, on the one hand, and those of the National Police and the Civil Guard, on the other, do not exchange information. The cooperation is reduced to the personal relationships of individual agents who, without the knowledge of their superiors, exchange information to put safety first.”

Much of the inter-agency discord revolves around the failure of Catalan police to monitor Abdelbaki Es-Satti, the now-deceased mastermind of the Barcelona plot. Es-Satti was a Moroccan national who served a four-year sentence in a Spanish prison on a conviction for drug trafficking.

While in prison, Es-Satti is believed to have met Rachid Aglif, one of the main plotters of the 2004 Madrid bomb attacks that killed 192 people and wounded 2,000. Es-Satti should have been deported at the end of his sentence in April 2014, but a Spanish judge ruled that sending him back to Morocco would be a violation of his human rights.

After prison, Es-Satti served as an imam at a mosque in the Catalan town of Ripoll, where he is suspected of organizing the Barcelona terror cell and radicalizing its members.

More than a year before the attack, the director of the Ripoll mosque reported Es-Satti to local police as part of a security protocol to monitor Muslim preachers. Catalan authorities said they did not place Es-Satti on a watch list because the central government in Madrid withheld information about his jihadist background.

Es-Satti was killed the night before the Barcelona attack when a bomb accidentally detonated in a house where he was preparing explosives. Investigators later found more than a hundred large orange gas canisters, as well as traces of triacetone triperoxide (TATP), an explosive substance frequently used by members of the Islamic State in Europe.

Catalan police have been accused of botching the initial investigation by failing to link the house explosion to the terror cell. That mistake allowed the jihadists to roam free for an entire day before they carried out their attacks in Las Ramblas and Cambrils. It also remains unclear why neighbors failed to report suspicious activity at the house, which had been foreclosed by a bank and which the 12-member terror cell had illegally occupied for more than six months.

The information gaps hardly ended there. Spanish media have reported that two months before the attack, the CIA had warned Catalan police that Barcelona — specifically the area of Las Ramblas, the city’s main tourist thoroughfare — was being targeted by jihadists.

Catalan officials, however, failed to install bollards or to take other preventive security measures which would have prevented the jihadists from plowing a vehicle through dense crowds on a busy pedestrian-only street.

Barcelona’s left-wing mayor, Ada Colau, has defended her refusal to “fill Barcelona with barriers” by insisting that it must remain “a city of liberty.”

Then there is the broader political dimension. In an effort to promote Catalan nationalism and the Catalan language, Catalonian pro-independence parties have deliberately encouraged immigration from Muslim countries in the belief that these immigrants (unlike those from Latin America) would learn the Catalan language rather than Spanish.

Today Catalonia not only has the highest Muslim population in Spain, it is also one of the most Islamized regions of the country. Its 7.5 million inhabitants include an estimated 510,000 Muslims, who account for around seven percent of the total Catalan population.

In some Catalan towns, however, the Muslim population is above 40 percent of the overall population.

A leaked U.S. diplomatic cable dating back to 2007 warned that the vast majority of Muslim migrants in Catalonia are unmarried males without legal documentation: “They live on the edges of Spanish society, they do not speak the language, they are often unemployed.... Individually, these circumstances would provide fertile ground for terrorist recruitment; taken together, the threat is clear....”

Even if that warning made an impression, the split between local and national institutions on the issue created a dangerous gap in security. The failure to heed intelligence warnings, enhance physical security and identify suspicious activity, combined with a slavish commitment to multiculturalism, political correctness and mass migration amid the idiosyncrasies of local politics, are all factors which enabled the Barcelona attackers.

Therein is the fundamental lesson for America: by refusing to cooperate with the federal government on law enforcement, sanctuary cities can undermine the war on terror at a time when local, state and federal agencies should be working together to protect the American homeland.