Mishkat al-Masabih
A man of the family of al-Khattab reported the Prophet (ﷺ) as saying, "He who purposely comes to visit me will be under my protection on the day of resurrection; he who lives in Medina and endures its difficulty will have me as a witness and intercessor on the day of resurrection; and he who dies in one of the two sacred territories will be raised by God on the day of resurrection among those who will be safe." Ibn ‘Umar traced the following back to the Prophet, "He who performs the pilgrimage and visits my grave after my death will be like him who visited me in my lifetime." Baihaqi transmitted the two traditions in Shu’ab al-iman.
وَعَنْ رَجُلٍ مِنْ آلِ الْخَطَّابِ عَنِ النَّبِيِّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ قَالَ: «مَنْ زَارَنِي مُتَعَمِّدًا كَانَ فِي جِوَارِي يَوْمَ الْقِيَامَةِ وَمَنْ سَكَنَ الْمَدِينَةَ وَصَبَرَ عَلَى بَلَائِهَا كُنْتُ لَهُ شَهِيدًا وَشَفِيعًا يَوْمَ الْقِيَامَةِ وَمَنْ مَاتَ فِي أَحَدِ الْحَرَمَيْنِ بَعَثَهُ اللَّهُ مِنَ الْآمِنِينَ يَوْمَ الْقِيَامَة» وَعَنِ ابْنِ عُمَرَ مَرْفُوعًا: «مَنْ حَجَّ فَزَارَ قَبْرِي بَعْدَ مَوْتِي كَانَ كَمَنْ زَارَنِي فِي حَياتِي» . رَوَاهُمَا الْبَيْهَقِيّ فِي شعب الْإِيمَان
Reference