Mujahid's invasion of Sardinia
In 1015 and again in 1016, the forces of Mujāhid al-ʿĀmirī from the taifa of Denia and the Balearics, in the east of Muslim Spain (al-Andalus), attacked Sardinia and attempted to establish control over it. In both these years joint expeditions from the maritime republics of Pisa and Genoa repelled the invaders. These Pisan–Genoese expeditions to Sardinia were approved and supported by the Papacy, and modern historians often see them as proto-Crusades. After their victory, the Italian cities turned on each other, and the Pisans obtained hegemony over the island at the expense of their erstwhile ally. For this reason, the Christian sources for the expedition are primarily from Pisa, which celebrated its double victory over the Muslims and the Genoese with an inscription on the walls of its Duomo.

Background
Denia had perhaps hosted a naval squadron under the Caliphs of Córdoba in the tenth century; its port was "very good and very old". According to al-Idrīsī, as quoted in al-Himyarī, its shipyards were important in outfitting the caliphal fleet, and the fleet launched against Sardinia may have originated in them. In 940 or 941, the Caliphate signed treaties with Amalfi, Barcelona, Narbonne and the judgeships of Sardinia promising safe conduct in the western Mediterranean, an area where they had been subject to raids from Muslim pirates based out of Fraxinetum, the Balearic Islands and the eastern ports of Spain, the so-called Sharq al-Andalus (including Denia and the famous pirate base at Pechina). There is a record of an embassy from Sardinia to Córdoba shortly after the treaty, and from 943 to c. 1000 there are no recorded Muslim attacks on the Christian ports of the western Mediterranean.

The Carolingian navy had a presence in both Pisa and Genoa in the early ninth century. The north Italian cities had sent ships to protect Sardinia from a Muslim fleet in 829, but it was probably a Muslim fleet operating out of Sardinia that raided Rome in 841. The period of the late tenth and early eleventh centuries corresponded with a large growth in Pisa's population and in its geographical extent: its walls and fortifications doubled in scope as its suburbs grew. It entered into frequent territorial disputes with neighbouring Lucca, often violent, and its need for imports grew commensurately. Genoa, with even less hinterland to support its citizens and its shipyards, was also pressured into looking for new markets.

The Annales pisani antiquissimi, the civic annals of Pisa compiled by Bernardus Maragonis, record only a few events from the tenth century, and all have to do with the waging of war. In 970 "the Pisans were in Calabria", probably making war on its Muslim occupants in order to secure safe passage for their merchants through the Strait of Messina that separated Muslim Sicily from the peninsula. The Annales also record a Muslims naval attack on Pisa in 1004 and a Pisan victory over the Muslims off Reggio in 1005. The Muslim assault of 1004 may have originated in Spain. The Pisan attack was likely a response, and perhaps a serious attempt to put an end to Muslim piracy, for which Reggio served as a base. In 1006 an embassy from the Byzantine emperor Basil II to the court of the caliph Hishām II released some Andalusian soldiers that had been captured off the coasts of Corsica and Sardinia. Sicily, Corsica and Sardinia comprised the "route of the islands", which linked the north Italian towns to the markets of northern Africa and the eastern Mediterranean. Without control of the islands the expansion of Pisan and Genoese trade would have been severely hampered. The rise of Pisan and Genoese trade in connection with increased military activity, especially against the enemies of the Christendom, has a contemporary parallel on the other side of Italy in the growing Republic of Venice.

In 1011 the Pisan annals record that a "fleet from Spain" came to destroy the city, which suggests that the aggression was planned and organised and not merely a piratical raid. The most probable source of that fleet was the port of Denia, then ruled by Mujāhid al-ʿĀmirī (Mogehid). According to the chronicle of Ibn ʿIdhārī, Mujāhid received Denia from the Córdoban hājib Muhammad Ibn Abī ʿĀmir al-Manṣūr, who died in 1002. It is unclear from Ibn ʿIdhārī whether Mujāhid conquered the Balearics from his base at Denia, or whether he took control of Denia from a base in the Balearics. A Muslim enclave may have been established in Sardinia by Mujāhid's Balearic predecessor around 1000. In 1004, Pope John VIII urged the Christian powers to expel the Muslims from the island, which lay directly across the sea from Rome.

First expeditions (1015)
Mujāhid was probably motivated to conquer Sardinia in order to legitimise his power in Denia and the Balearics. A civil war (fitna) had broken out between various factions (taifas) after 1009 in the declining caliphate. A freed slave, Mujāhid found it necessary to legitimise his position by appointing a puppet caliph, ʿAbd Allāh ibn ʿUbayd Allāh ibn Walīd al-Muʿiṭī, in 1013. He probably saw an opportunity to secure his authority by waging a holy war (jihād), a device which had been used effectively by the man who appointed Mujāhid to rule Denia, al-Manṣūr. The conquest of Sardinia was thus undertaken in the name of al-Muʿiṭī, and the Islamic historian Ibn al-Khatīb praised Mujāhid before God for his piety in the event. One school of Islamic jurisprudence, represented in Mujāhid's day by al-Mawardī, recognised  "emirs by conquest", those like Mujāhid who had a right to rule lands they conquered for Islam.

In 1015 Mujāhid came to Sardinia with 120 ships, a large number which confirms that the expedition was not designed for raiding. The twelfth-century Pisan Liber maiolichinus, a history of the 1113–1115 Balearic Islands expedition, records that Mujāhid controlled all of the Sardinian coastal plain. In the Pisan histories of the time the expedition to Sardinia of 1015 is described tersely: "the Pisans and Genoese made war with Mujāhid in Sardinia, and defeated him by the grace of God" and "the Pisans and Genoese defended Sardinia." The annals covering the years 1005–16 are quoted in their entirety below. The dating of the expedition to 1015 is based on the Pisan calendar, which also dates Mujāhid's second expedition to 1017:

The account of the Liber maiolichinus is more detailed, although it excludes the Genoese, and so is probably referring to the 1015 expedition. It reports that even the Pisan nobles, in their eagerness, took turns rowing the galleys. It also compares them to starving lions rushing their prey. Mujāhid fled at the approach of the Italians, according to the Liber, which does not mention an actual engagement in 1015.

Second Muslim expedition (1016)
Mujāhid returned to Sardinia in 1016 intending a more thorough conquest of the island. To this end he brought along a reported thousand horses from the Balearics. On these islands, which were renowned for their horses and mules, Mujāhid had reformed the tax system and put the stables at the service of the government in preparation for his expedition. He arrived off Sardinia with a large fleet and a landing force capable of a rapid conquest. The local Sardinian ruler, Salusio, the judge of Cagliari, was killed in the fighting and the organised resistance broke down. His troops may have met up with garrisons that had remained on the island after the failed expedition of 1015. He also established a beachhead at Luni, on the coast between Genoa and Pisa, according to the eleventh-century German chronicler and bishop Thietmar of Merseburg (Thitmarus), who mis-dates the event to 1015. Luni was reportedly taken by surprise, but the citizens and the bishop managed to flee. Both town and countryside were pillaged without resistance.

To solidify his conquest, Mujāhid immediately set about building cities using the local Sards for slave labour (he may have had some buried alive in the walls of his new city). The area he controlled, the plain between the central mountains and the sea, corresponded roughly to the Judicature of Cagliari (regnum Calaritanum in the Liber, III, 45), whose judge he had defeated and killed. The site of one Islamic fortification can be approximated, for a Greek charter of 1081 makes reference to a "castro de Mugete" (castle of Mujāhid) near Cagliari, the chief city and port of the judicature. Archaeological research in the 1970s uncovered what may be Roman baths modified to fit Islamic tastes near Quartucciu.

It is also possible that an Arab population had been present on the island for some time if it had indeed served as the staging area for the assault on Rome in 841. Medieval cartographers called the southeastern Sardinian coast from Arbatax south Sarabus, a corruption of the Sard for "the Arabs", and the very name "Arbatax" may derive from ārbaʿa, meaning "four", a possible reference to the four Byzantine forts which lined that section of the coast. The liberus de paniliu, a designation for the "semi-free Christian children of Muslim slaves", appear in several eleventh-century donation charters from the region. Religious diversity, owing to a large endemic Arab population, may also explain the slowness with which monasticism of either the Western or Eastern variety encroached upon the area.

Second Christian expedition (1016)
The presence of Ilario Cao, a Cardinal from Sardinia, in the curia of Pope Benedict VIII—"a warlike pope, who has been compared to Julius II ... [b]ut his role in the conflict with [Mujāhid] ... elevates him to a higher plane"—was probably instrumental in obtaining papal approval and even active support of a military venture to Sardinia. Benedict even granted privileges to those who took part in the campaign and granted it a "vermilion banner". One fourteenth-century source records that a papal legate was sent to preach it as a crusade, but this is probably anachronistic. Thietmar, a much closer source, describes the attack on Luni by the "enemies of Christ" and how Benedict responded by calling "all leaders (rectores) and protectors (defensores) of the Church" to kill them and chase them away:
Travelling by ship, the Saracens came to Lombardy and seized the city of Luna whose bishop was barely able to escape. Then, without opposition and in complete security, they occupied the whole region and abused the occupants' womenfolk. When news of these events reached Pope Benedict, he summoned all the rectors and defenders of holy mother church, and both asked and commanded them to join him in an attack on these presumptuous enemies of Christ. With God's help, they could annihilate them. Furthermore, he secretly sent a powerful fleet to eliminate any possibility that the enemy might retreat. When informed of these developments, the Saracen king was initially disdainful, but then, with a few members of his entourage, chose to escape the approaching danger on a ship. Yet his forces rallied and, attacking first, quickly put the approaching enemy to flight. Sad to say, the slaughter continued for three days and nights. At last, placated by the groans of the pious, God relented. . .
Thietmar goes on to say that Mujāhid sent a sack of chestnuts to the pope to illustrate the number of Muslim soldiers he would unleash on Christendom. Benedict sent back a sack of millet representing the number of Christian soldiers that would meet them. The entire story has been called into question, but that the papacy took a direct interest in Mujāhid's attacks on Christians lands cannot be doubted. Thietmar says that the pope sent a fleet, but this probably only means that he encouraged the maritime republics to send fleets on behalf of all Christendom and not that the Christian fleet comprised "for the most part hired mercenaries", as was once suggested.

The combined forces of Pisa and Genoa, arriving in May, vastly outnumbered those of Mujāhid.  The emir's troops were already restless because of a lack of sufficient booty, and so he tried to flee. His fleet was badly battered by a storm as it passed through a rocky cove, according to the Arabic sources, and the Pisans and Genoese picked off the remaining ships, capturing Mujāhid's mother and his heir. His mother seems to have been originally a European captured and sold into slavery, as she chose to remain with "her people" after her capture on Sardinia. His son and heir, ʿAlī, remained a hostage for a number of years. Those Muslims who survived the wreck of their ships were slaughtered onshore by the local populace.

Aftermath
According to the Annales pisani, the Pisans and the Genoese fought for control of the island in the aftermath of their victory over Denia. In the first engagement, in Porto Torres, the Pisans were victorious. Pisa secured a papal privilege and strengthened their control over the island by installing monks from Saint-Victor de Marseille and expelling all those monks from rival Monte Cassino whom they could capture. Her interest in curtailing Islamic piracy did not stop at Sardinia. In 1034 her fleet destroyed the pirate base of Bône. The later eleventh-century campaigns of Pisa and Genoa, like the Mahdia campaign of 1087, were performed "for the remission of [their] sins", according to Crusades scholar Jonathan Riley-Smith. Pisa's last outpost on Sardinia was conquered by James II of Aragon, who laid claim to the Kingdom of Sardinia and Corsica, in 1325.

Mujāhid never attacked Sardinia again, despite a late medieval story about an invasion of 1021, in which "the Pisans on the island were hunted down". Historically, in 1017 pirates operating out of his taifa failed in a largescale assault on Narbonne. Mujāhid also continued raiding the County of Barcelona and exacting tribute into the 1020s, when the count, Berenguer Ramon I, called upon a Norman adventurer, Roger I of Tosny, to protect him. Following his father's death, ʿAlī continued his policy of raiding Christian territory. The Abbey of Lérins was attacked several times and its monks sold as slaves in the market of Denia. In 1056 Genoa adopted a statute requiring foreigners who were in the city during a time of Muslim aggression to aid the republic (in reconnaissance, for instance). These attacks on the coasts of northern Italy and southern France may have been launched from Corsica. The "evil men" which Pope Gregory VII (1073–85) ordered Bishop Landulf of Pisa (1070–75) to remove from the island may have been Muslims.

Denia under Mujāhid's successors did not ignore Sardinia. In 1044 and again in 1056 an Andalusian Muslim scholar who had embarked at Denia was killed in action off Sardinia. Probably both academics were participating in jihād. There are likewise two Sard saint's lives dating from the late eleventh century which depict Islamic persecution on the island. San Saturno di Cagliari, an adaption of a life of Saint Saturninus, incorporates a prayer for deliverance from Muslim piracy. The local legend of Saint Gavin and his martyrdom during the Roman persecutions was transformed about this time into Sa vitta et sa morte et passione de Sanctu Gavinu Prothu et Januariu, an account of his persecutions by Muslims. It would take a century for peace to come to the sea lanes around Sardinia. In 1150 Pisa and the taifa of Valencia, which included Denia, signed a treaty whereby the latter would not exact tribute from Pisan ships on their way to Sardinia.

Notes

Bibliography

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

11th-century crusades
Medieval Sardinia
Conflicts in 1015
Conflicts in 1016
Military history of the Mediterranean
1015 in Europe
1016 in Europe
Republic of Pisa
11th century in the Republic of Genoa