The mosque was founded by the Fatimid general Jawhar al-Siqilli in 970 for the new capital, al-Qahira, and was completed in 972. Teaching began within a few years, which is why it is regularly described as one of the oldest continuously operating centres of learning anywhere.
The name itself is a claim: al-Azhar, 'the most luminous', is usually connected to al-Zahra — 'the radiant' — the epithet of Fatima, the Prophet's daughter, from whom the Fatimid dynasty took its name and its legitimacy.
The Fatimids were Shia and Al-Azhar began as a Shia foundation. After Saladin ended Fatimid rule in the twelfth century the mosque was reoriented to Sunni teaching, which is what it has been ever since.
Successive Mamluk emirs and sultans endowed madrasas and minarets around the original prayer hall, and Abd al-Rahman Katkhuda made major additions in the eighteenth century, including the gate most visitors now enter by.
Its scholars have mattered politically as well as religiously — al-Azhar was a centre of resistance to the French occupation in 1798 — and the modern university added faculties of medicine, engineering and languages in the twentieth century alongside the traditional curriculum, with a women's campus since the 1960s.