It was originally constructed in the 11th century by the king Abd al-Aziz as an almúnia or recreation residence on the outskirts of the city.
In 1364, in the course of the war with Castile, the troops of Peter the Cruel burned it down and looted it.