Why did ISIS attack Barcelona? The history of Islam in Spain holds answers.

BARCELONA, Spain — When the ominous maps first appeared two years ago, residents of Barcelona scoffed, if they noticed the tabloid news about their home at all. Drawn by ISIS, the maps showed Spain and Portugal in black, signifying territory controlled by the jihadi terror group. And the maps came with a promise: “We will take Spain back” — by 2020, ISIS said.

The threat centered on the long-ago empire of al-Andalus — the Islamic caliphate that began when Muslim warriors from North Africa, known as Moors, arrived on Spanish soil in the early eighth century, quickly running out the ruling Visigoths and extending Muslim rule across the Iberian peninsula, including Barcelona, on the Mediterranean coast close to present-day France.

Historians are enamored of Moorish culture and art, but for many Spaniards, the al-Andalus era is the nadir of their country’s history. The caliphate’s influence in southern Spain, Andalusia, where it lasted nearly eight centuries, is evidenced in both the region’s name and in stunning Islamic architecture such as Granada’s Alhambra palace. But the eighth-century Muslim occupation in the Northeast region of Catalonia lasted but 80 years and is nearly as forgotten as the chilling ISIS maps.

The maps suddenly seemed relevant again on Thursday, when, on one of Barcelona’s most-photographed and tourist-traveled sites, the wide pedestrian way called La Rambla, a white rental van jumped the curb and raced along the median walkway, swerving back and forth on a lethal ride that created a stampede of terrified tourists. Thirteen people were killed and scores injured in the attack, for which ISIS claimed responsibility.

Not long after, five suspected jihadis were killed by Spanish police in Cambrils, some 75 miles to the southwest, after they drove into a crowd of pedestrians, injuring seven. The attackers reportedly wore explosive belts, and police believe the original plan for La Rambla may have included explosives as well. Even with three alleged perpetrators arrested — the suspected van driver, 18-year-old Moussa Oukabir, whose Facebook page is said to have expressed a desire to “kill the unbelievers,” was still being sought Friday morning — the Rambla rampage raises troubling questions. How can authorities secure a pedestrian-friendly city famous for fiestas in huge squares and for streets like La Rambla, flanked by flower stalls and terraces serving up pitchers of sangria, where at any given moment, thousands of tourists can be found strolling along the tree-lined median of land that leads to the famous statue of Columbus pointing over the sea?

The most chilling question of all, however, is whether ISIS is trying to make good on its threat to reconquer the lands that once constituted al-Andalus.

Whatever can be said about the centuries between 711 and 1492, Moorish rule was a far cry from the violent and oppressive caliphate run by ISIS. European civilization was shaped, more than most Westerners realize, by al-Andalus, which long before the rise of the Ottomans in the East represented the crucial frontier between Christianity and Islam. When the Moors set off north from Barcelona to conquer land under Frankish rule, they were repelled from France and ultimately from Barcelona, which along with principalities along the northeastern coast constituted a buffer zone that became independent-minded Catalonia, a region still not tightly bonded with the rest of Spain.

But in cities like Toledo, Córdoba and Granada, the Islamic civilization thrived. Irrigation was introduced along with novel crops like oranges and lemons. Islamic medicine pioneered surgery for cataracts and hemorrhoids. Roads were illuminated by gas lights; scribes, whose ranks included women, translated the classics of ancient Rome and Greece, works that otherwise would have been lost. Christians and Jews were not forced to convert, though those who didn’t take up the Muslim faith of their rulers were hit with hefty taxes.

Nevertheless, an occupation it was — and through the decades warriors from the North, among them El Cid, whittled away at the caliphate’s lands until it contained little but Granada, with its palace and surrounding mountains. In 1492, the forces of Isabel and Ferdinand finally wrested away that prize, routing the caliphate’s leader Boabdil, who departed his palace with tears in his eyes over losing his beloved Alhambra.

For 512 years, the expulsion of the Moors appeared to be an immutable fact — until 2004, when on a March morning four trains, packed with commuters, pulled into Madrid’s Atocha station — and bombs simultaneously exploded on all. The atrocity that killed 191 civilians was attributed to Islamic terrorists with a self-proclaimed affiliation with al-Qaida and a set of grievances that dated back five centuries.

For the next decade, the calls for the reconquest appeared to have faded. But in 2014, Spanish Interior Minister Jorge Fernández Díaz, upon breaking up an ISIS cell, acknowledged that the dream was still alive among jihadis. “Clearly Spain forms part of the strategic objections of global jihad,” he told reporters. “We are not the only ones, but we are in their sights.”

Shortly thereafter, New York-based Gatestone Institute reported that “calls to reconquer al-Andalus are becoming more frequent and more strident” and that ISIS had launched a social media campaign — involving images of well-known Spanish monuments juxtaposed with the slogan “Long live the Islamic State” and photos of the ISIS black flag.

Since then, Spanish security forces, considered to be Europe’s most vigilant, have arrested hundreds of suspected jihadis and ISIS recruiters. And at the end of June, Spanish police broke up a planned massacre in Mallorca, where jihadis had hoped to wrest control of the island that was once a crown jewel in al-Andalus.

Between the surveillance and the arrests — or perhaps due to ISIS leader al-Baghdadi, whose nickname was Messi when he played on his mosque’s soccer team, and his rumored fondness for the local soccer club where the real Messi plays — Barcelona appeared lucky, charmed, somehow immune from fate of other European tourist magnets. But that all changed yesterday. And a renewed vigilence is underway to keep Barcelona and Spain from appearing as conquered territories on ISIS’ map.