The Messenger of Allah ﷺ said, "I had previously forbidden you from visiting graves, but Muhammad has now been granted permission to visit his mother's grave, so visit them, for they remind one of the Hereafter."
حدثنا محمد بن بشار ومحمود بن غيلان والحسن بن علي الخلال قالوا حدثنا أبو عاصم النبيل حدثنا سفيان عن علقمة بن مرثد
قال رسول الله ﷺ قد كنت نهيتكم عن زيارة القبور فقد أذن لمحمد في زيارة قبر أمه فزوروها فإنها تذكر الآخرة
Muslim also narrated it, in the Book of Funerals, chapter on the Prophet ﷺ seeking permission from his Lord, Mighty and Sublime, to visit his mother's grave, hadith 977, from the report of Sufyan Thawri, in a similar wording.On this subject there are also narrations from Abu Saeed [Bayhaqi 4/77], Ibn Masud [Ibn Majah, hadith 1571], Anas [Ahmad 3/237], Abu Hurairah [Muslim, hadith 976], and Umm Salama [Tabarani in al-Kabir 23/278, hadith 602].