ash-Shafiee refuted Maalik when people of Al-Andalus started taking blessings from his cap

Imam ash-Shafiee refuted Imam Maalik When people of Al-Andalus started venerating Imam Maalik to the extreme that they started taking blessings from a cap of Imam Maalik.
al Bayhaqi said:
أن الشافعي إنما وضع الكتاب على «مالك» أنه بلغه أن بأندلس كُمَّةً لمالك – يعني قلنسوة – يُستسقى بها. وكان يقال لهم: قال رسول الله، صلى الله عليه وسلم فيقولون: قال مالك: فقال الشافعي: إن مالكا آدمي قد يخطئ ويغلط. فالذي دعاه إلى أن وضع عليه هذا الكتاب: ذلك. وكان يقول: كرهت أن أفعل ذلك، ولكني استخرت الله في ذلك سنة كذا
Imam ash-Shafiee wrote a book in refutation of Imam Maalik. The reason for that was, some people in al Andalus started taking blessings from the cap of Imam Malik. There state was that if someone would say this is what Prophet peace be upon him said, they would say but Imam Maalik said this.
Ash-Shafiee said: Maalik was a Man who can make mistakes and sometimes he is wrong too. Due to this situation ash-Shafiee was forced to write this response. ash-Shafiee would also say: I don\t like it (writing response against Imam Maalik) but i did Istikhara in such and such year.
مناقب الشافعی: 1/508-509، توالي التأسيس ص147

He wrote this refutation so that people may stop venerating the Imam to the extremes.

Credits: Brother Shahrukh Khaan.