In
antiquity, there was most probably a
pagan temple in place of the current mosque. During the Christian era, it was converted into a church named after
John the Baptist. In the Medieval Age, the city was captured first by the
Rashidun Caliphate in 637, by the
Byzantine Empire in 969, by the
Seljuk Turks in 1084, by the
Crusades in 1098, and by the
Baibars of the
Mamluk Sultanate in 1268. Concurrently in each case, the status of the building was changed from church to mosque and from mosque to church. However, in the inscription of the mosque, it reads that it was rebuilt in 1275 soon after Baibars had converted it to a mosque. Wendy Mayer and Pauline Allen suggest that the mosque is built on top of the former
church of Cassian, however this remains uncertain as
Yaqut al-Rumi mentions a shrine of Habib as a place of pilgrimage at the beginning of the thirteenth century when Antioch was under Frankish rule which was not that same church. The mosque was demolished during the 1853 earthquake. It was rebuilt by the
Ottomans but the minaret was left standing and is older. The
shadirvan (
ablution fountain) is a later addition. The mosque was severely damaged in the 2023 earthquake, and was fully restored by 2026. ==Namesake==