Sayyiduna Ali bin Abi Talib (may Allah be pleased with him) narrates: During the illness in which he passed away, the Prophet (peace and blessings be upon him) said to me: "Give the people permission to come in to me." I gave permission, and the Prophet (peace and blessings be upon him) said: "May Allah Almighty curse a people who took the graves of their prophets as a mosque." Then he fainted. When he came to, he said: "O Ali, give the people permission to come in to me." I gave them permission to come in, and he said: "May Allah Almighty curse a people who took the graves of their prophets as a mosque." Then he fainted again. When he regained consciousness, he said: "O Ali, give the people permission to come in to me." I gave permission, and he said: "May Allah Almighty curse a people who took the graves of their prophets as a mosque." (The narrator says:) That is, he said this three times during his final illness.
Bazzar recorded it; its chain contains Abu al-Ruqad, from whom no one other than Hunayf al-Mu'adhdhin narrated, and the rest of its narrators have been declared trustworthy.
Hadith Referenceمجمع الزوائد ومنبع الفوائد / كتاب الصلاة / 2063