'''''Muhammed ´Idris ash-Shafi´i''''' eller ''Al-Shafi'i'' har kallats ”den  islamiska rättens fader” och han har tillskrivits grundandet av den numera tredje största sunnitiska rättskolan som också är uppkallad efter honom: Shafi'i.

Al-Shafi'i levde 767-820 e.kr. i Mecka-Medina området under abbasiderna (750-950). Islams territoriella dominans hade ända sedan Muhammeds tid expanderat kraftigt vilket medfört en utveckling mot mångfald och pluralism i religionen och i rättsväsendet. Bredvid koranen och haditherna (berättelser om Muhammed) hade den lokala sedvänjan sunna och sunt förnuft ra'y utvecklats till att bli en del av stommen som de rättsliga utlåtandena vilade på. Detta skapade regionala skillnader i rättsväsendet som al-Shafi'i motsatte sig. 

För att motverka detta började man systematiskt gå tillbaka till koranen och tolka dess budskap, man samlade in och bedömde sanningshalten i de många hadither som florerade. Och med dessa källor som bas och ett visst mänskligt resonemang skapade man ett nytt, mer enhetligt, system för den islamiska rättvetenskapen fiqh. I hela denna process spelade al-Shafi´i en stor roll.

<!--Beginning of the Template:Infobox Muslim scholars-->
{{Infobox_Muslim scholars |      
 <!-- Scroll down to edit this page -->    
 <!-- Philosopher Category -->     
 notability = Muslim jurist|        
 era = Islamic golden age|         
 color = #cef2e0 |       

 <!-- Images -->   
 image_name = |          
 image_caption = |       
 signature = |   
 
 <!-- Information -->      
 name = '''Muhammad ibn Idris ash-Shafi`i'''|  
 title='''Imam al-Shafi'i'''|      
 birth = 767|       
 death = 820 <ref>Ira Lapidus, ''A History of Islamic Societies.''  pg. 86.  Cambridge University Press 2002.</ref>|       
 Maddhab = Sunni Shafi'i|     
 school tradition= | 
 Ethnicity = |
 Region = |      
 notable idea= |
 main_interests = Fiqh |      
 influences = Imam Malik<ref>The Origins of Islamic Law: The Qurʼan, the Muwaṭṭaʼ and Madinan ʻAmal, by Yasin Dutton, pg. 16</ref> |          
 influenced = |          
 works = |       
}}     

'''Al-Shafi'i''', Arabic jurist (150 AH/767 AD - 204 AH/820 AD). He was active in juridical matters and his teaching eventually led to the Shafi'i school of ''fiqh'' (or Madh'hab) named after him. Hence he is often called Imam al-Shafi'i.

His full name was '''Abu Abdullah Muhammad ibn Idrīs al-Shafi'i''' ('''''').

==Introduction==

The biography of al-Shafi'i is difficult to trace. The oldest surviving biography goes back to Ibn Abi Hatim al-Razi (died 327H/939)  and is no more than a collection of anecdotes, some of them dubious. The first real biography is by Ahmad Bayhaqi (died 458H/1066) and is filled with pious legends. The following is what seems to be a sensible reading.

==Biography==
==Family==
Al-Shafi'i belonged to the Qurayshi clan Banu Muttalib which was the sister clan of the Banu Hashim to which Muhammad and the Abbasid caliphs belonged. Hence he had connections in the highest social circles, but he grew up in poverty. 

===767 &ndash; 786: Al-Mansur to Al-Hadi's era===
====Early life, Imam Malik====
He was born in Gaza and moved to Mecca when he was about ten. He is reported to have studied with the "School of Mecca" (which might not even have existed, although some scholars are reported to have been active there). Then he moved  to Madinah and became a disciple of Malik ibn Anas.

===786 &ndash; 809: Harun al-Rashid's era===
After Malik's death in 796 he went into government service. This attempt at a career ended badly in 803 CE (187 Ah). 

After that he lived in Mecca, Baghdad and finally Egypt.

Among his teachers were Malik ibn Anas and Muhammad ibn al Hasan al Shaybani, whom he studied under in Madinah and Baghdad.

At the time of Harun ar-Rashid, he had an appointment in Yemen, as a judge in Najran. Sunnis portray that his devotion to justice, even when it meant criticizing the governor, caused him some problems, and he was taken before the Caliph, falsely accused of aiding the Alawis in a revolt. At this time, al Shaybani was the chief justice, and his defense of ash-Shafi'i, coupled with ash-Shafi'i’s own eloquent defense, convinced Harun ar-Rashid to dismiss the charge, and to direct al Shaybani to take ash-Shafi'i to Baghdad.He was also a staunch critic of Al-Waqidi's writings on Sirah.

In Baghdad, he developed his first madhab, influenced by the teachings of both Imam Abu Hanifa and Imam Malik. Thus, his work there is known as “al Madhab al Qadim lil Imam as Shafi’i,” or the Old School of ash-Shafi'i.

===809 &ndash; 813: Al-Amin's era===

===813 &ndash; 820: Al-Ma'mun's era===
====Fiqh research====
It appears that all of his surviving writings were done in retirement in Egypt during the last five years of his life.

Al-Shafi'i was controversial in his own time but, as history has shown, he won his point. Starting from the Maliki position of reliance (largely) upon tradition in legal matters he came into contact with and opposed the Hanafi position of reliance (largely) upon common sense. He reached the conclusion that tradition was indeed the proper basis for legal decisions, but only if that tradition was based upon the prophet and no one else. 

The Hanafis, of course, were not willing to exchange all their common sense for hadiths and the Maliki's were not willing to give up traditions just because they had no prophetic hadiths supporting them. As time went by, however, both the Hanafis and Malikis have grown to conform to Shafi'i's idea that only prophetic hadiths matter. The fourth school of fiqh came later.

Shafi'i probably did not expect what happened next. There was an explosion of prophetic entire science had to be invented to handle them.  

====Death====
He died at the age of 54 on the 30th of Rajab in the Hijri year 204 (or, 820 AD). He was buried in al-Fustat, Egypt.

==Views==
It is stated in ''Rawdah al-Manazir fi al-Awai'l wa al-'Awakhir'' that <ref>Rawdah-al-Manazir fi al-Awai'l wa al 'Awakhir Volume 11 page 133</ref>:

This view of Imam Shafi'i has also been attributed to him by his student Abu al-Fida <ref>Tarikh Abul Fida Volume 1 under the chapter addressing the events of 45 Hijri [http://www.answering-ansar.org/answers/muawiya/al_bashar.jpg]</ref>

==Legacy==
Saladin built a madrassa on the site of his death. Saladin's brother Afdal built a mausoleum for him in 1211 after the defeat of the Fatamids. It remains a site where people petition for justice.