In 456 A.D., when the Roman Empire was sinking fast, the Vandals of Africa occupied Caralis along with the other coastal cities of Sardinia.
In 534 the Vandals were defeated at Tricamari - a place some 30 km from Carthage - by the troops of the Eastern Emperor Justinian and Sardinia thus became Byzantine. The island was divided into districts called merèie, governed by a judge residing in Caralis (Cagliari) and garrisoned by an army stationed in Forum Traiani (nowadays Fordongianus) under the command of a dux. In this period Christianity spread throughout the island, except in the Barbagia regions. Here, towards the end of the sixth century, a short-lived independent domain re-established itself, with Sardinian lay and religious traditions, one of its kings being Ospitone.
From 640 to 732 the Arabs occupied North Africa, Spain and part of France. In 827 they began their occupation of Sicily. Sardinia remained isolated and was forced to defend itself; thus, the judges assumed overall command with civil and military powers.
The continual raids and attacks by the Islamised Berbers on the Sardinian shores began in 710 and grew ever more ruinous with time. Their inhabitants abandoned the coastal towns and cities. In order to afford a better defence of the island the provincial judge assigned his civil and military powers to his four lieutenants in Cagliari, Torres or Logudoro, Arborea and Gallura. Around 900, the lieutenants gained their independence, in turn becoming judices (in Sardinian judikes means king) of their own logo or state.

A letter written by Pope Nicholas I in 864 mentions for the first time the “Sardinian judges”. Their autonomy became clear in a later letter written by Pope John VIII, which defined them “princes”. At the dawn of the judicial era Sardinia had some 330,000 inhabitants, 120,000 of them free. 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). The Church was also powerful, and at this time it had completely abandoned the Eastern Rite. The arrival of the Benedictines and other monks boosted the agriculture in a land which was extremely underdeveloped.
Each one of these four Sardinian states called “Giudicati” constituted a sovereign kingdom, not patrimonial but independent since it was not the property of the monarch. But they were at the same time democratic since all the most important issues of national interest were not for the king (or ‘giudice’) himself to decide but were a matter for the representatives of the people gathered in assembly called ‘corona de logu’. Each kingdom had its own fortified boundaries to protect its own political and trading affairs, its own parliament, own laws (cartas de logu), own national languages, own chancelleries, own state emblems and symbols, etc.
The kingdom or "giudicato" of Cagliari was politically pro-Genoese. It was brought to an end in 1258 when its capital, S. Igia, was stormed and destroyed by an alliance of Sardinian-Pisan forces. The territory then became a colony of Pisa.
The kingdom of Torres, too, was pro-Genoese and came to an end in 1259, on the death of the "giudicessa" Adelasia. The territory was divided up between the Dorian family of Genoa and the Bas-Serra family of Arborea, while the city of Sassari became an autonomous city-republic.
The kingdom of Gallura ended in the year 1288, when the last "giudice" Nino Visconti, one of Dante's friends, was driven out by the Pisans who occupied the territory.
The kingdom of Arborea was almost always under the political and cultural influence of the powerful marine republic of Pisa. It lasted some 520 years, with Oristano as its capital.
In 1297, in order to settle diplomatically the War of the Vespers, which broke out in 1282 between the Angevins and Aragon's over the possession of Sicily, Pope Boniface VIII established a hypothetical "regnum Sardiniae et Corsicae". The Pope gave it to the Catalan Jaume II the Just, king of the Crown of Aragon (a confederation made up of the kingdoms of Aragon and Valencia, plus the peasants of Catalonia), promising him support should he wish to conquer Pisan Sardinia in exchange for Sicily.
In 1323 Jaume II of Aragon formed an alliance with the kings of Arborea and, following a military campaign which lasted a year or so, occupied the Pisa territories of Cagliari and Gallura along with the city of Sassari, naming them "kingdom of Sardinia and Corsica".
In 1353, for reasons of state survival, war broke out between the kingdom of Arborea and the kingdom of "Sardinia and Corsica", part of the Crown of Aragon.
In 1354 the Aragon's seized Alghero and reshaped it into an entirely Catalan city, which still today displays its Iberian origins.
In 1353 Pere IV of Aragon, called "the Cerimonious", granted legislative autonomy (a parliament) to the kingdom of "Sardinia and Corsica" which was followed in due course by self-government (Viceroy) and judicial independence (Royal Hearing).
From 1365 to 1409 the kings or "giudici" of Arborea Mariano IV, Ugone III, Mariano V (assisted by his mother Eleonora, the famous ‘giudicessa’ regent) and Guglielmo III (French grandson of Eleonora) succeeded in occupying almost all Sardinia except for the Castle of Cagliari .
In 1409 Marti the younger, king of Sicily ad heir to Aragon, defeated the judicable Sardinians at Sanluri and conquered once and for all the entire land. Shortly afterwards he died in Cagliari of malaria, without issue, and consequently the Crown of Aragon passed into the hands of the Castilians Trastàmara - and in particular Ferran I of Antequera and his descendants - with the Compromise of Caspe in 1412.