The citadel is located on a spot where already in Justinian times a fortress was erected. However, the present citadel owns its existence to the Seljuks, who took the city in 1071-1098. The oldest finds on the site date to the chalcolithic period (3700-3500 BC).
Impressive, isn't it? However, in 1270 the Mongols did get into the city (and, I pressume, the citadel), destroying the city. Three years later the Mameluk sultan Baibars took it, leaving his emir Dulkadir to rule (the Mameluks had there centre of power in far-off Cairo). In 1516 Selim incorporated the city into the Ottoman empire. And between 1832 and 1840 the Egyptians were back for a short while. One wonders what's the use of a citadel to start with.