King Alfonso I of Aragon died at its walls in 1134 while trying to conquer it during the Battle of Fraga. It was conquered from the Moors by the Count Ramon Berenguer IV of Barcelona in 1149.