 The Crusaders wrested control of Gaza from the Fatimids in 1100 . According to the chronicler William of Tyre , the Crusaders found it uninhabited and in ruins . Unable to totally refortify the hilltop on which Gaza was built , due to a lack of resources , King Baldwin III built a small castle there in 1149 . The possession of Gaza completed the military encirclement of the Fatimid @-@ held city of Ascalon to the north . After the castle 's construction , Baldwin granted it and the surrounding region to the Knights Templar . He also had the Great Mosque converted into the Cathedral of Saint John . 
