A madhhab (, , pl. , ) refers to any school of thought within Islamic jurisprudence. The major Sunni madhhab are Hanafi, Maliki, Shafi'i, and Hanbali. They emerged in the ninth and tenth centuries CE and by the twelfth century almost all Islamic jurists aligned themselves with a particular madhhab. These four schools recognize each other's validity and they have interacted in legal debate over the centuries. Rulings (Fatwa) of these schools are followed across the Muslim world without exclusive regional restrictions, but they each came to dominate in different parts of the world.

For example, the Maliki school is predominant in North and West Africa; the Hanafi school in South and Central Asia; the Shafi'i school in East Africa and Southeast Asia; and the Hanbali school in North and Central Arabia. The first centuries of Islam also witnessed a number of short-lived Sunni madhhabs. The Zahiri school, which is considered to be endangered, continues to exert influence over legal thought. The development of Shia legal schools occurred along the lines of theological differences and resulted in the formation of the Ja'fari madhhab amongst Twelver Shias, as well as the Isma'ili and Zaydi madhhabs amongst Isma'ilis and Zaydis respectively, whose differences from Sunni legal schools are roughly of the same order as the differences among Sunni schools. The Ibadi legal school, distinct from Sunni and Shia madhhabs, is predominant in Oman. Unlike Sunnis, Shias, and Ibadis, non-denominational Muslims are not affiliated with any madhhab.Rane, Halim, Jacqui Ewart, and John Martinkus. "Islam and the Muslim World." Media Framing of the Muslim World. Palgrave Macmillan UK, 2014. 15-28Obydenkova, Anastassia V. "Religious pluralism in Russia." Politics of religion and nationalism: Federalism, consociationalism and secession, Routledge (2014): 36-49

The transformations of Islamic legal institutions in the modern era have had profound implications for the madhhab system. With the spread of codified state laws in the Muslim world, the influence of the madhhabs beyond personal ritual practice depends on the status accorded to them within the national legal system. State law codification commonly drew on rulings from multiple madhhabs, and legal professionals trained in modern law schools have largely replaced traditional ulama as interpreters of the resulting laws. In the 20th century, some jurists began to assert their intellectual independence from traditional madhhabs. With the spread of Salafi influence and reformist currents in the 20th century; a handful of Salafi scholars have asserted independence from being strictly bound by the traditional legal mechanisms of the four schools. Nevertheless, the majority of Sunni scholarship continues to uphold post-classical creedal belief in rigorously adhering (taqlid) to one of the four schools in all legal details.

The Amman Message, which was endorsed in 2005 by prominent Islamic scholars around the world, recognized four Sunni schools (Hanafi, Maliki, Shafi'i, Hanbali), two Shia schools (Ja'fari, Zaydi), the Ibadi school, and the Zahiri school. Schools of Islamic jurisprudence are located in Pakistan, Iran, Bangladesh, India, Indonesia, Nigeria, Egypt, Turkey, Afghanistan, Kazakhstan, Russia, China, the Philippines, Algeria, Libya, Saudi Arabia, and multiple other countries.

History / Relationship with politics Early Islamic law emerged from a combination of administrative and community-based practices in the conquered territories and shaped by the religious and ethical principles of Islam. While retaining certain aspects of pre-Islamic laws and customs —and modifying others— this legal system aimed to establish norms of Islamic conduct and resolving disputes arising within the community. This was a gradual process of development —taking place within the cultural and political context of the era and region— amidst retrospective constructs and traditions that reflected the understandings and solutions of the social fabric; it unfolded in circles of learning where students and aspiring scholars gathered to acquire knowledge from a local master and deliberate on religious matters—circles that would later come to be known as schools of law.

While the Sunni tradition (Hanafi, Maliki, Shafi'i, Hanbali) provided a broad jurisprudence in practical matters, its legal framework developed under the shadow of the Umayyad and Abbasid state apparatuses, prioritizing political stability, communal cohesion, and a public law rooted in Qurayshi lineage.Crone, Patricia (2004). God's Rule: Government and Islam. New York: Columbia University Press. pp. 21–33 (Chapter 3: "The Umayyads and the Caliphate"), pp. 125–147 (Chapter 9: "The Sunnis"). ISBN 978-0231132909.Lapidus, Ira M. (2014). A History of Islamic Societies (3rd ed.). Cambridge: Cambridge University Press. pp. 114–128 (Part I: "The Formation of Classical Islamic Society"). ISBN 978-0521514309.

Conversely, Shi'a schools (Twelver, Zaidi, Ismaili) grounded both political and religious legitimacy in the theology of the Imamate, framing authority as an exclusive, divinely appointed right reserved for the infallible progeny of the Ahl al-Bayt.Momen, Moojan (1985). An Introduction to Shi'i Islam: The History and Doctrines of Twelver Shi'ism. New Haven: Yale University Press. pp. 147–160 (Chapter 8: "The Doctrine of the Imamate"). ISBN 978-0300035315.Daftary, Farhad (2007). The Isma'ilis: Their History and Doctrines (2nd ed.). Cambridge: Cambridge University Press. pp. 83–102 (Chapter 3: "Early Isma'ilism and the Fatimid State"). ISBN 978-0521616362. In radical opposition to both of these lineage- and charisma-centered aristocracies, the Ibadi school—derived from the moderate wing of the Kharijite movement—rejected tribal and genealogical elitism, advocating for a merit-based, elective, and accountable model of public governance that eventually became predominant in Oman.Hoffman, Valerie J. (2012). The Essentials of Ibadi Islam. Syracuse: Syracuse University Press. pp. 3–28 (Chapter 1: "Origin and Early History of the Ibadis"), pp. 53–72 (Chapter 3: "Ibadi Political Thought"). ISBN 978-0815632887.Wilkinson, John C. (1987). The Imamate Tradition of Oman. Cambridge: Cambridge University Press. pp. 135–158 (Chapter 7: "The Elective Imamate and Ibadi Law"). ISBN 978-0521327138.

Ultimately, each legal school developed its distinct scriptural canon, hadith collections, and hermeneutical methodologies primarily to substantiate and legitimize its underlying political philosophy and framework of authority.Rabb, Intisar A. (2009). "Fiqh". In Esposito, John L. (ed.). The Oxford Encyclopedia of the Islamic World. Oxford: Oxford University Press. Vol. 2, pp. 263–273. doi:10.1093/acref/9780195305135.001.0001. ISBN 978-0195305135.Brown, Jonathan A. C. (2009). Hadith: Muhammad's Legacy in the Medieval and Modern World. Oxford: Oneworld Publications. pp. 123–149 (Chapter 5: "Hadith in Shi'ism and Other Sectarian Traditions"). ISBN 978-1851686636.

"Ancient" schools According to John Burton, "modern research shows" that fiqh was first "regionally organized" with "considerable disagreement and variety of view". In the second century of Islam, schools of fiqh were noted for the loyalty of their jurists to the legal practices of their local communities, whether Mecca, Kufa, Basra, Syria, etc.Burton, Islamic Theories of Abrogation, 1990: p.13 (Egypt's school in Fustat was a branch of Medina's school of law and followed such practices—up until the end of the 8th century—as basing verdict on one single witness, not two, and the oath of the claimant. Its principal jurist in the second half of the 8th century was al-Layth b. Sa'd.) Al-Shafiʽi wrote that, "every capital of the Muslims is a seat of learning whose people follow the opinion of one of their countrymen in most of his teachings".

The "real basis" of legal doctrine in these "ancient schools" was not a body of reports of Muhammad's sayings, doings, silent approval (the Hadith) or even those of his Companions, but the "living tradition" of the school as "expressed in the consensus of the scholars", according to Joseph Schacht.

Al-Shafi‘i and afterwards It has been asserted that madhahib were consolidated in the 9th and 10th centuries as a means of excluding dogmatic theologians, government officials and non-Sunni sects from religious discourse. Historians have differed regarding the times at which the various schools emerged. One interpretation is that Sunni Islam was categorised into four groups: the Hanafites, Malikites, Shafi'ites, and Zahirites.Mohammad Sharif Khan and Mohammad Anwar Saleem, Muslim Philosophy And Philosophers, pg. 34. New Delhi: Ashish Publishing House, 1994. Later, the Hanbalites and Jarirites developed two more schools; then various dynasties effected the eventual exclusion of the Jarirites;Christopher Melchert, The Formation of the Sunni Schools of Law: 9th–10th Centuries C.E., pg. 178. Leiden: Brill Publishers, 1997. eventually, the Zahirites were also excluded when the Mamluk Sultanate established a total of four independent judicial positions, thus solidifying the Maliki, Hanafi, Shafi'i, and Hanbali schools. During the era of the Islamic Gunpowders, the Ottoman Empire reaffirmed the official status of these four schools as a reaction to Shi'ite Persia.Chibli Mallat, Introduction to Middle Eastern Law, pg. 116. Oxford: Oxford University Press, 2007. Some are of the view that Sunni jurisprudence falls into two groups: Ahl al-Ra'i ("people of opinions", emphasizing scholarly judgment and reason) and Ahl al-Hadith ("people of traditions", emphasizing strict interpretation of scripture).Murtada Mutahhari, The Role of Ijtihad in Legislation, Al-Tawhid volume IV, No.2, Publisher: Islamic Thought Foundation

10th century Shi'ite scholar Ibn al-Nadim named eight groups: Maliki, Hanafi, Shafi'i, Zahiri, Imami Shi'ite, Ahl al-Hadith, Jariri, and Kharijite.Devin J. Stewart, THE STRUCTURE OF THE FIHRIST: IBN AL-NADIM AS HISTORIAN OF ISLAMIC LEGAL AND THEOLOGICAL SCHOOLS, International Journal of Middle East Studies, v.39, pg.369–387, Cambridge University Press, 2007 Abu Thawr also had a school named after him. In the 12th century Jariri and Zahiri schools were absorbed by the Shafi'i and Hanbali schools respectively. Ibn Khaldun defined only three Sunni madhahib: Hanafi, Zahiri, and one encompassing the Shafi'i, Maliki, and Hanbali schools as existing initially,Ignác Goldziher, The Zahiris, pg. 5. Trns. Wolfgang Behn, intro. Camilla Adang. Volume three of Brill Classics in Islam. Leiden: Brill Publishers, 2008. Meinhaj Hussain, A New Medina, , Grande Strategy, 5 January 2012 noting that by the 14th-century historian the Zahiri school had become extinct, only for it to be revived again in parts of the Muslim world by the mid-20th century.Daniel W. Brown, Rethinking Tradition in Modern Islamic Thought: Vol. 5 of Cambridge Middle East Studies, pgs. 28 and 32. Cambridge: Cambridge University Press, 1996. M. Mahmood, The Code of Muslim Family Laws, pg. 37. Pakistan Law Times Publications, 2006. 6th ed.Hassan Ahmed Ibrahim, "An Overview of al-Sadiq al-Madhi's Islamic Discourse." Taken from The Blackwell Companion to Contemporary Islamic Thought, pg. 172. Ed. Ibrahim Abu-Rabi'. Hoboken: Wiley-Blackwell, 2008.

Historically, the fiqh schools were often in political and academic conflict with one another, vying for favor with the ruling government in order to have their representatives appointed to legislative and especially judiciary positions.

Modern era