At the beginning of our book "Ṭabaqāt al-Shāfiʿiyyīn" (The Generations of the Shafi'is), we have recounted the biography of Imam Shafi'i at length. Here, we will mention him briefly. In this matter, we seek Allah's help.
Muḥammad b. Idrīs b. ʿAbbās b. ʿUthmān b. Shāfiʿī b. Sāʾib b. ʿUbayy b. ʿAbd Yazīd b. Hāshim b. al-Muṭṭalib b. ʿAbd Manāf b. Quṣayy al-Qurashī al-Muṭṭalibī. Sāʾib b. ʿUbayd became Muslim at the Battle of Badr. His son, Shāfiʿī b. Sāʾib, was among the younger Companions (ṣaḥāba).
Imam Shafi'i's mother was from the Azd tribe. When she was pregnant with him, she saw in a dream that the planet Jupiter emerged from her womb and descended upon Egypt. Then, its light spread to every land.
Imam Shafi'i was born in Gaza. There are also some reports that he was born in Asqalan or in Yemen. His birth year was the 150th year of the Hijra. He lost his father at a young age. His mother, so that his lineage would not be lost, took him to Mecca when he was two years old. He was raised in Mecca; at the age of seven, he recited the Qur'an, and at the age of ten, he memorized the Muwatta'. At the age of fifteen, he began issuing legal opinions (fatwas). According to another report, he began issuing fatwas at the age of eighteen. His shaykh, Muslim b. Khālid al-Zanjī, gave him permission to issue fatwas.
He was interested in language and poetry. He stayed among the Hudhayl tribe for about ten years. There is a weak report that he stayed for twenty years. From the Hudhayl, he learned the Arabic language and eloquence. He listened to many hadiths from a group of shaykhs and imams. He recited the Muwatta' he had memorized in the presence of Imam Mālik. Imam Mālik admired and praised his recitation and diligence.
After Muslim b. Khālid al-Zanjī, he learned the knowledge of the people of Hijaz from Imam Mālik. Many people also narrated from him, whose names we have listed in alphabetical order in two ranks.
By adhering to the chain of transmission through Shabl, Ibn Kathīr, Mujāhid, Ibn ʿAbbās, Ubayy b. Kaʿb, the Messenger of God (peace be upon him), Gabriel, and Allah the Exalted, Imam Shafi'i recited the Qur'an in the presence of Ismāʿīl b. Konstantīn.
Imam Shafi'i received lessons in jurisprudence (fiqh) from Muslim b. Khālid, Ibn Jurayj, ʿAṭāʾ, Ibn ʿAbbās, Ibn al-Zubayr, and, besides these last two, from another group of Companions (ṣaḥāba), among whom were ʿAmr b. ʿAlī, Ibn Masʿūd, Zayd b. Thābit, and others. All of these had learned jurisprudence from the Messenger of God (peace be upon him). Imam Shafi'i also took lessons in jurisprudence from Imam Mālik and other teachers. A group also learned jurisprudence from him, whose names we have mentioned. After them, many people up to our time have learned the science of jurisprudence from the books he wrote.
According to the narration of Ibn Abī Ḥātim, Imam Shafi'i served as a judge in Najrān, which was part of Yemen. Then, some people, out of fanaticism, denounced him to Hārūn al-Rashīd, claiming that he aspired to the caliphate. As a result, he was put in chains and, at the age of thirty, in the year 184 of the Hijra, was brought to Baghdad before the caliph Hārūn al-Rashīd, riding on a mule.
In the presence of the caliph, he debated with Muḥammad b. al-Ḥasan. Muḥammad b. al-Ḥasan spoke well of him. Hārūn al-Rashīd, realizing that the accusations against him were baseless, declared his innocence.
Muḥammad b. al-Ḥasan took him as his guest. Abū Yūsuf had died a year earlier. There is a weak report that he had died two years earlier. Muḥammad b. al-Ḥasan honored Imam Shafi'i. Imam Shafi'i, in turn, wrote down from him as much as a camel-load of transmissions. Then Hārūn al-Rashīd gave him 2,000 dinars (according to another report, 5,000 dinars).
Afterwards, Imam Shafi'i returned to Mecca. He distributed the money he had received to his relatives, cousins, and kinsfolk. Then, in the year 195 of the Hijra, he returned to Iraq.
This time, a group of scholars gathered around him, including Aḥmad b. Ḥanbal, Abū Thawr, Ḥusayn b. ʿAlī al-Karābisī, Ḥāris b. Shurayḥ al-Baqqāl, Abū ʿAbd al-Raḥmān al-Shāfiʿī, Zafarānī, and others. From there, he returned to Mecca. From Mecca, in the year 198 of the Hijra, he returned again to Baghdad. From Baghdad, he moved to Egypt and remained there until his death in the year 204 of the Hijra.
In Egypt, he compiled his book "al-Umm." This was among his later (jadīd) works, because this book was transmitted by the Egyptian Rabīʿ b. Sulaymān. According to Imām al-Ḥaramayn and others, however, this book is from his earlier (qawl qadīm) works. But this is a statement far from accuracy and a claim to be rejected. Allah knows best the truth.
Many great imams, among them ʿAbd al-Raḥmān b. Mahdī, praised Imam Shafi'i. ʿAbd al-Raḥmān asked him to write a book on legal methodology (uṣūl), and in response to this request, he wrote his "al-Risāla." ʿAbd al-Raḥmān would supplicate (dua) for him after every prayer.
Imam Shafi'i's teachers were: Mālik b. Anas, Qutayba b. Saʿīd (who used to say that Imam Shafi'i was an imam), Sufyān b. ʿUyayna, Yaḥyā b. Saʿīd al-Qaṭṭān (who also used to supplicate for Imam Shafi'i in his prayers), Abū ʿUbayd (who said: "I have not seen anyone more eloquent or more God-conscious [taqwa] than Imam Shafi'i"), Yaḥyā b. Aktham al-Qāḍī, Isḥāq b. Rāhawayh, Muḥammad b. al-Ḥasan, and others. To mention all the names of his teachers here would take up too much space.
Imam Aḥmad b. Ḥanbal supplicated for Imam Shafi'i after prayers for about forty years.
Abū Dāwūd narrated from Abū Hurayra that the Prophet (peace and blessings be upon him) said:

