After the fall of the Roman Empire, Sardinia was subject to several conquests. In 456, the Vandals, coming from North Africa, occupied the coastal cities of the island. In 534 the small Vandal forces surrendered immediately to the Byzantines when news of the Vandal collapse; thenceforth the island was part of the Byzantine Empire, included in the African prefecture. The local governor sat in Caralis. Starting from 705-706, the Saracens from North Africa (recently conquered by the Arab armies) harassed the population of the coastal cities. News about the political situation of Sardinian in the following centuries are scarce. Due to Saracen attacks, in the 9th century Tharros was abandoned in favor of Oristano; Caralis and numerous other coastal centres suffered the same fate. There are news of another massive Saracen sea attack in 1015 from Spain, led by one Mujahid (Latinized in Museto), who established a colony in the north in 1018-1028.
From the mid-11th century the Giudicati ("held by judges") appeared. The title of "Judge" was an heir of that of the Byzantine governor after the creation of the Exarchate of Africa in 582 (Judex Provinciae). In the 8th-9th centuries the four partes grew increasingly independent, the Byzantines being totally cut off from the Tyrrhenian Sea by the Muslim conquest of Sicily in 827. A letter of Pope Nicholas I of 864 mentions for the first time the "Sardinian judges"; their autonomy now clear in a later letter by Pope John VIII, which defined them "princes". At the dawn of the judicial era the Sardinia had some 330,000 inhabitants. These were subjected to the authority of local curators (administrators), in turn subjected to the judge (who also administrated justice and was the commander of the army).
There were four giudicati: Torres, Cagliari, Arborea and Gallura. Often at war one against the other, they made commercial concessions to the Pisanes, expecially the giudicato of Cagliari (who established a fortress in Caralis in 1216) and the Genoese. The first victim was the giudicato of Cagliari, destroyed by an alliance of the Pisane and the other three giudicati. In 1288 Pisa acquired also the giudicato of Torres, while that of Gallura was divided in the late 1290s between the two families of Bas Serra from Arborea and the Doria from Genoa. Sassari declared itself a philo-Genoese free commune in the same period.
In the early 14th century much of the eastern Sardinia, Caralis included, was under Pisan authority. The giudicato of Arborea survived until 1420. The most remarkable Sardinian figure of the Middle Ages, Eleonora d'Arborea, was co-ruler of that reign in the late 14th century: she laid the foundations for the laws that remained valid until 1827, the Carta de Logu.
In 1323 the Aragonese under Peter, son of King James II, disembarked at Palmas, near Iglesias, in south Sardinia. The Pisane intervened but where defeated both by sea and by land, and were forced to cease all the Carali area and the Gallura, mantaining only their castle in Carali. In 1353 Mariano III of Arborea, allied with the Doria, waged war against the Aragonese, defeating them at Decimum and besieging Sassari, but being unable to capture Cagliari. The Peace of Sanluri (1355) granted a period of tranquillity, but hostilities were resumed in 1395, with the Arborea initially able to capture much of the Island. However, in 1409 the Aragonese crushed a Genoese fleet coming in support the Sardinians, and destroyed the judicial army at the battle of Sanluri. Oristano, the Arborean capital, fell on March 29, 1410.
The loss of the independence, the firm Aragonese (later Spanish) rule, with the introduction of a sterile feudalism, provoked an unstoppable decline of Sardinia.
A short period of resurgence occurred under the local noble Leonardo Alagon, marquess of Oristano, who managed to defeat the viceroyal army in the 1470s but was later crushed at the battle of Macomer (1478), ending any further hope of independence for the island.