 Baybars ended the Ayyubid and early Mamluk tradition of selecting a Shafi'i scholar as "qadi al-qudah" (chief judge) and instead had a "qadi al-qudah" appointed from each of the four madhabs.This policy change may have been partly motivated by a desire to accommodate an increasingly diverse Muslim population whose components had immigrated to Egypt from regions where other "madhabs" were prevalent.Ultimately, however, the diffusion of the post of "qadi al-qudah" among the four "madhabs" enabled Mamluk sultans to act as patrons for each "madhab" and thus gain more influence over them.