Some secular writers have theorized that the mausoleum of Imam al-Shafi (d. 204H) (may Allah have mercy on him) was first built by Salah ad-Din Ayyubi (may Allah have mercy on him) to compete with the Shiites/Fatimids and some have even claimed that it was built because of Asharite-Hanbali rivalry. They assume that such structures did not exist prior to that or that it was evolved into Sunnism from the Shiites. Not surprisingly the Wahhabiyya pick on such theories to attack these structures.
On the contrary to such narrow theories, Imam Ibn ‘Abd Barr (d. 463H), the maliki jurist & theologian, who died about 60 years before Salah ad-Din was even born, records in his book الانتقاء في فضائل الثلاثة الأئمة الفقهاء (“The Hand-Picked Excellent Merits of the Three Great Jurisprudent Imâms”), in his biographical entry on Ibn ‘Abdal Hakam (d. 257H), that:
وَعِنْدَهُ مَاتَ الشَّافِعِيُّ وَدُفِنَ فِي وَسَطِ قُبُورِ بَنِي عَبْدِ الْحَكِم بِمِصْرَ وَبَنَوْا عَلَى قَبْرِهِ قُبَّةً
“al-Shafi died, he was buried in between the graves of the sons of Ibn Abd al-Hakam in Misr (Egypt)and a dome was built over his grave“
Its clear that not only was the structure over his grave existing prior to Salah ad-Din but shows also a dome being built during the 2nd century (of Islamic calendar) itself at the time of Ibn ‘Abd al Hakam in whose land Imam al-Shafi’s resting place lie. And Allah Most Gracious has allowed the preservation and honor of the place to remain till today. May Allah continue to preserve it and protect it from the plots of the horns of Shaytan.