The earliest building at this location belonged to the count of
Fonnollède (Fennoullies) in 1021.
In the 13th century, a keep that had replaced earlier buildings
was bequeathed by the viscounts of Carcassonne
to their vassal, the family de Termes. (there is another Cathar
Castle at Termes
not far away).
In 1210 Aguilar was occupied by Simon de Montfort, whose soldiers
had captured the owner Raymond de Termes
and imprisoned him in a dark dungeon in Carcassonne.
Militarily, the castle lay dormant for the next 30 years, until
Raymond's son Olivier de Termes
took back the castle in the brief revolt by the young Viscount Trencavel
against the crusaders. Aguilar then became the refuge of faidits,
Cathar knights and lords dispossessed of their own strongholds,
but it changed hands again when the revolt failed.
In 1246 a royal garrison was installed to supervise the Aragon frontier.
Olivier made an alliance with king Louis IX, who purchased the castle from him in 1260. Despite the heavy fortifications, the castle would be continually under siege by opponents of French rule until the 16th century.
This is one of the "Five Sons of Carcassonne", along with Queribus, Termes, Peyrepertuse and Puilaurens: five castles strategically placed to defend the French border against the Spanish. It lost all strategic importance after the Treaty of the Pyrenees in 1659 when the border was moved even further south to its present position along the crest of the Pyrenees.