The biography of al-Shāfi‘i is difficult to trace. Dawud al-Zahiri was said to be the first to write such a biography, but the book has been lost. 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 fantastic. The first real biography is by Ahmad Bayhaqi (died 458H/1066) and is filled with what a modernist eye would qualify as pious legends. The following is what seems to be a sensible reading, according to a modern reductionist point of view.
Al-Shāfi‘ī belonged to the Qurayshi clan Banu Muttalib which was the sister clan of the Banu Hashim to which Muhammad''alaihis-salām'' and the Abbasid caliphs belonged. Hence he had connections in the highest social circles, but he grew up in poverty.
Early life, studies with az-Zanji in Mecca
He was born in Gaza, near the town of Asqalan. While still a child, his father died in Syria and thus his mother decided to move to Mecca when he was about two years old. His family roots were from Yemen, and there were more members of his family in Mecca, where his mother believed he would better be taken care of. He is reported to have studied under Muslim Ibn Khalid az-Zanji, the Mufti of Mecca at his time and is considered the first teacher of Imam ash-Shafi'i.
Studies with Imam Malik in Medina
He moved to Medina to teach others of the message of Islam and be taught by Malik ibn Anas. He memorized Muwatta Imam Malik at a very early age whereby Imam Malik was very impressed with his memory and knowledge.
786 – 809: Harun al-Rashid's era
After that he lived in Mecca, Baghdad and finally Egypt. Among his teachers were Malik ibn Anas and Muḥammad ibn al-Ḥasan al-Shaybānī, whom he studied under in Madinah and Baghdad. He was appointed as a judge in Najran in the time of Harun ar-Rashid. 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. al-Shaybānī was the chief justice at the time, 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 he directed al-Shaybānī 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 madh'hab, 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 – 813: Al-Amin's era
Muhammad ibn Harun al-Amin (787–813) (Arabic: محمد الأمين بن هارون الرشيد), Abbasid Caliph. He succeeded his father, Harun al-Rashid in 809 and ruled until he was killed in 813. 813 – 820:
He died at the age of 54 on the 30th of Rajab in 204 AH (820 AD). He was buried in al-Fustat, Egypt.
Imam al-Shāfi‘ī developed the science of fiqh unifying 'revealed sources' - the Quran and hadith - with human reasoning to provide a basis in law. With this systematization of shari'a he provided a legacy of unity for all Muslims and forestalled the development of independent, regionally based legal systems. The four Sunni legals schools or madhhabs- keep their traditions within the framework that Shafi'i established. Imam al-Shāfi‘ī gives his name to one of these legal schools Shafi'i fiqh - the Shafi'i school - which is followed in many different places in the Islamic world: Indonesia, Malaysia, Egypt, Somalia, Yemen as well as Sri Lanka and southern parts of India. Saladin built a madrassa and a shrine on the site of his tomb. 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.
Among the followers of Imam al-Shāfi‘ī’s school were:
Al-Nawawi Ibn Hajar Asqalani
Hafidh ibn Kathir
He authored more than 100 books. Al-Risala — The best known book by al-Shafi'i in which he examined principles of jurisprudence. The book has been translated into English. Kitab al-Umm - his main surviving text on Shafi'i fiqh Musnad ash-Shafi'i (on hadith) - it is available with arrangement, Arabic 'Tartib', by Ahmad ibn Abd ar-Rahman al-Banna
Many stories are told about the childhood and life of ash-Shafi'i, and it is difficult to separate truth from myth: Tradition says that he memorized the Qur’an at the age of seven; by ten, he had memorized the Muwatta of Imam Malik; he was a mufti (given authorization to issue fatwa) at the age of fifteen. He recited the Qur’an every day in prayer, and twice a day in Ramadan. Some apocryphal accounts claim he was very handsome, that his beard did not exceed the length of his fist, and that it was very black. He wore a ring that was inscribed with the words, “Allah suffices Muhammad ibn Idris as a reliance.” He was also known to be very generous. He was also an accomplished archer, a poet, and some accounts call him the most eloquent of his time. Some accounts claim that there were a group of Bedouin who would come and sit to listen to him, not for the sake of learning, but just to listen to his eloquent use of the language. Even in latter eras, his speeches and works were used by Arabic grammarians. He was given the title of Nasir al Sunnah, the Defender of the Sunnah. He loved Muhammad''alaihis-salām'' very deeply. Al Muzani said of him, “He said in the Old School: ‘Supplication ends with the invocation of blessings on the Prophet, and its end is but by means of it.’” Al-Karabisi said: “I heard al-Shafi’i say that he disliked for someone to say ‘the Messenger’ (al-Rasul), but that he should say ‘Allah’s Messenger’ (Rasul Allah) out of veneration for him.” He divided his night into three parts: one for writing, one for praying, and one for sleeping. Apocryphal accounts claim that Imam Ahmad said of ash-Shafi'i, “I never saw anyone adhere more to hadith than al-Shafi’i. No one preceded him in writing down the hadith in a book.” Imam Ahmad is also claimed to have said, “Not one of the scholars of hadith touched an inkwell nor a pen except he owed a huge debt to al-Shafi’i.” Imam Muhammad al-Shaybani said, “If the scholars of hadith speak, it is in the language of al Shafi’i.” Shah Waliullah, a 18th century Sunni Islamic scholar stated:
“ A Mujadid appears at the end of every century: The Mujtahid of the 1st century was Imam of Ahlul Sunnah, Umar bin Abdul Aziz. The Mujadid of the 2nd century was Imam of Ahlul Sunnah Muhammad Idrees as-Shafi'i the Mujadid of the 3rd century was Imam of Ahlul Sunnah Abu Hasan Ashari the Mujadid of the 4th century was Abu Abdullah Hakim Nishapuri. ”
According to many accounts he was said to have a photographic memory. One anecdote states that he would always cover one side of a book while reading because a casual glance at the other page would commit it to memory.