Sahih Muslim 532
Narration text is preserved in its supplied Arabic and English. Translated interfaces and reading guides do not add narration translations in other languages.
إِنِّي أَبْرَأُ إِلَى اللَّهِ أَنْ يَكُونَ لِي مِنْكُمْ خَلِيلٌ فَإِنَّ اللَّهَ تَعَالَى قَدِ اتَّخَذَنِي خَلِيلاً كَمَا اتَّخَذَ إِبْرَاهِيمَ خَلِيلاً وَلَوْ كُنْتُ مُتَّخِذًا مِنْ أُمَّتِي خَلِيلاً لاَتَّخَذْتُ أَبَا بَكْرٍ خَلِيلاً أَلاَ وَإِنَّ مَنْ كَانَ قَبْلَكُمْ كَانُوا يَتَّخِذُونَ قُبُورَ أَنْبِيَائِهِمْ وَصَالِحِيهِمْ مَسَاجِدَ أَلاَ فَلاَ تَتَّخِذُوا الْقُبُورَ مَسَاجِدَ إِنِّي أَنْهَاكُمْ عَنْ ذَلِكَ "
Jundub reported:
I heard from the Messenger of Allah (ﷺ) five days before his death and he said: I stand acquitted before Allah that I took any one of you as friend, for Allah has taken me as His friend, as he took Ibrahim as His friend. Had I taken any one of my Ummah as a friend, I would have taken Abu Bakr as a friend. Beware of those who preceded you and used to take the graves of their prophets and righteous men as places of worship, but you must not take graves as mosques; I forbid you to do that.
Full reference and source
Sahih Muslim 532 In-book : Book 5, Hadith 28 USC-MSA web (English) : Book 4, Hadith 1083 (deprecated)
View source on Sunnah.com (opens in a new tab)