This is the donjon, we see it after having entered the old gate.
What we see now probably dates from reconstructive work after an earlier version, dating from around 1112, had been demolished by Nur al-Din during campaigns in 1167 and 1171. That work was executed about 1188, then an earthquake necessitated further improvement, so roughly the current donjon is from the 13th century. It fell into Muslim hands in 1271 when Sultan Baybars took it, when on his way to Krak des Chevaliers.