In 1324 the Kingdom of Aragon conquered Cagliari (Castel di Castro) after a battle against the Pisans.
The kings of Aragon, and later the kings of Spain (who were also Kings of Sardinia), were represented in Cagliari by a viceroy.