Uqba bin Amir reported,

The Messenger of Allah ﷺ said, "That I should walk on a hot coal or a sword, or mend my sandal with my foot, is dearer to me than walking on the grave of a Muslim. And I would not care whether I relieved myself in the middle of the graves or in the middle of the marketplace."

Azami 3795

Sahih

عن عقبة بن عامر قال

قال رسول الله ﷺ: لأن أمشي على جمرة أو سيف، أو أخصف نعلي برجلي، أحب إلي من أن أمشي على قبر مسلم، وما أبالي أوسط القبور قضيت حاجتي، أو وسط السوق.

الأعظمي 3795صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Funerals
Chapter
Graves
Section
Prohibition of sitting on a grave, stepping on it, and praying on it
Numbering
Jami al-Kamil 3795 (2nd edition)
Azami 3795