كتاب الجنائز
11
The Book of Prayer - Funerals
(36)
Chapter: The prophet (saws) asked his Lord for permission to visit the grave of his mother
(36)
باب اسْتِئْذَانِ النَّبِيِّ صلى الله عليه وسلم رَبَّهُ عَزَّ وَجَلَّ فِي زِيَارَةِ قَبْرِ أُمِّهِ ‏‏

Abu Huraira reported:

The Apostle of Allah (ﷺ) visited the grave of his mother and he wept, and moved others around him to tears, and said: I sought permission from my Lord to beg forgiveness for her but it was not granted to me, and I sought permission to visit her grave and it was granted to me so visit the graves, for that makes you mindful of death.
حَدَّثَنَا أَبُو بَكْرِ بْنُ أَبِي شَيْبَةَ، وَزُهَيْرُ بْنُ حَرْبٍ، قَالاَ حَدَّثَنَا مُحَمَّدُ بْنُ عُبَيْدٍ، عَنْ يَزِيدَ بْنِ كَيْسَانَ، عَنْ أَبِي حَازِمٍ، عَنْ أَبِي هُرَيْرَةَ، قَالَ زَارَ النَّبِيُّ صلى الله عليه وسلم قَبْرَ أُمِّهِ فَبَكَى وَأَبْكَى مَنْ حَوْلَهُ فَقَالَ ‏ "‏ اسْتَأْذَنْتُ رَبِّي فِي أَنْ أَسْتَغْفِرَ لَهَا فَلَمْ يُؤْذَنْ لِي وَاسْتَأْذَنْتُهُ فِي أَنْ أَزُورَ قَبْرَهَا فَأُذِنَ لِي فَزُورُوا الْقُبُورَ فَإِنَّهَا تُذَكِّرُ الْمَوْتَ ‏"‏ ‏.‏
Reference : Sahih Muslim 976 b
In-book reference : Book 11, Hadith 135
USC-MSA web (English) reference : Book 4, Hadith 2130
  (deprecated numbering scheme)