Segorbe Castle was an Arabian alcázar (palace or castle). Very little remains of the original alcázar, but the large complex was a residence of lords, dukes and kings for over a millennium.
.After the Muslim king of Valencia, Zayd Abu Zayd, converted to Christianity and declared himself an ally and vassal of King James I of Aragon, he ceded the fortress to James in 1229 and became governor general of Valencia on his behalf. The castle became a sanctuary for Zayd Abu Zayd himself when he was killed by Dynamil Zayyan until James captured the castle in 1245, and placed Abu Zayd in command of an army to assist in the retaking of Valencia.
The castle had a peak in the 14th and 15th centuries, culminating in the holding of General Courts by King Martin of Aragon, who had made the city his residence.
In 1784, urban expansion of Segorbe beyond the original medieval fortifications required further construction, and new walls were built. After the works were completed, the new walls had eight gates.
References:The Walls of Constantinople are a series of defensive stone walls that have surrounded and protected the city of Constantinople (today Istanbul) since its founding as the new capital of the Roman Empire by Constantine the Great. With numerous additions and modifications during their history, they were the last great fortification system of antiquity, and one of the most complex and elaborate systems ever built. They were also the largest and strongest fortification in both the ancient and medieval world.
Initially built by Constantine the Great, the walls surrounded the new city on all sides, protecting it against attack from both sea and land. As the city grew, the famous double line of the Theodosian Walls was built in the 5th century. Although the other sections of the walls were less elaborate, they were, when well-manned, almost impregnable for any medieval besieger.