The main buildings were started by the Arabs in the X century. They controlled the town until the arrival of King Pedro III of Aragon, who after a successful siege, reformed the castle considerably. It was last occupied by the soldiers of King Felipe II, since when it has been abandoned..