Sunan an-Nasa'i, Book 21, Hadith 218 (In-Book)

It was narrated that Abu Hurairah said: "The Messenger of Allah visited the grave of his mother and wept, and caused those around him to weep. He said: 'I asked my Lord for permission to pray for forgiveness for her and He did not give me permission, and I asked Him for permission to visit her grave and He gave me permission, so visit the graves, for they will remind you of death."'

أَخْبَرَنَا قُتَيْبَةُ، قَالَ حَدَّثَنَا مُحَمَّدُ بْنُ عُبَيْدٍ، عَنْ يَزِيدَ بْنِ كَيْسَانَ، عَنْ أَبِي حَازِمٍ، عَنْ أَبِي هُرَيْرَةَ، قَالَ ‏:‏ زَارَ رَسُولُ اللَّهِ صلى الله عليه وسلم قَبْرَ أُمِّهِ فَبَكَى وَأَبْكَى مَنْ حَوْلَهُ وَقَالَ ‏:‏ ‏ "‏ اسْتَأْذَنْتُ رَبِّي عَزَّ وَجَلَّ فِي أَنْ أَسْتَغْفِرَ لَهَا فَلَمْ يُؤْذَنْ لِي، وَاسْتَأْذَنْتُ فِي أَنْ أَزُورَ قَبْرَهَا فَأَذِنَ لِي، فَزُورُوا الْقُبُورَ فَإِنَّهَا تُذَكِّرُكُمُ الْمَوْتَ ‏" ‏ ‏.‏

sunnah.com