Muʿādh reported—Ibn ʿAwn narrated to us, saying: A man once asked Nāfiʿ, “Did Ibn ʿUmar use to offer greetings at the grave?” He replied, “Yes, indeed. I saw him a hundred times—nay, more than a hundred times—come to the grave, stand beside it and say:
‘Peace be upon the Prophet; peace be upon Abū Bakr; peace be upon my father.’
In another version, which Imām Aḥmad cites as supporting evidence, it adds: ‘Then he would leave.’ This report is likewise transmitted by Mālik in the Muwaṭṭaʾ.
[Issues related to graves: visiting them, praying near them, turning them into places of worship, and building upon them]
Visiting graves is generally permissible, even the graves of non-Muslims. For in Ṣaḥīḥ Muslim Abū Hurayrah relates that the Prophet, peace and blessings be upon him, said: “I asked my Lord for permission to seek forgiveness for my mother, but He did not permit me; then I asked Him for permission to visit her grave, and He allowed me.”
He also narrates in the same collection: “The Messenger of Allah, peace and blessings be upon him, visited his mother’s grave and wept, causing those around him to weep. He said, ‘I asked my Lord for permission to seek forgiveness for her, but He did not permit me; and I asked Him for permission to visit…’”