Sahih Muslim Book 004, Hadith Number 2127.
Chapter : What is to be said while visiting the graveyard and the supplication to be offered for the dead lying in the graves.
Muhammad b. Qais said (to the people): Should I not narrate to you (a Hadith of the Holy Prophet) on my authority and on the authority of my mother? We thought that he meant the mother who had given him birth. He (Muhammad b. Qais) then reported that it was 'Aisha who had narrated this: Should I not narrate to you about myself and about the Messenger of Allah (may peace be upon him)? We said: Yes. She said: When it was my turn for Allah's Messenger (may peace be upon him) to spend the night with me, he turned his side, put on his mantle and took off his shoes and placed them near his feet, and spread the corner of his shawl on his bed and then lay down till he thought that I had gone to sleep. He took hold of his mantle slowly and put on the shoes slowly, and opened the door and went out and then closed it lightly. I covered my head, put on my veil and tightened my waist wrapper, and then went out following his steps till he reached Baqi'. He stood there and he stood for a long time. He then lifted his hands three times, and then returned and I also returned. He hastened his steps and I also hastened my steps. He ran and I too ran. He came (to the house) and I also came (to the house). I, however, preceded him and I entered (the house), and as I lay down in the bed, he (the Holy Prophet) entered the (house), and said: Why is it, O 'Aisha, that you are out of breath? I said: There is nothing. He said: Tell me or the Subtle and the Aware would inform me. I said: Messenger of Allah, may my father and mother be ransom for you, and then I told him (the whole story). He said: Was it the darkness (of your shadow) that I saw in front of me? I said: Yes. He struck me on the chest which caused me pain, and then said: Did you think that Allah and His Apostle would deal unjustly with you? She said: Whatsoever the people conceal, Allah will know it. He said: Gabriel came to me when you saw me. He called me and he concealed it from you. I responded to his call, but I too concealed it from you (for he did not come to you), as you were not fully dressed. I thought that you had gone to sleep, and I did not like to awaken you, fearing that you may be frightened. He (Gabriel) said: Your Lord has commanded you to go to the inhabitants of Baqi' (to those lying in the graves) and beg pardon for them. I said: Messenger of Allah, how should I pray for them (How should I beg forgiveness for them)? He said: Say, Peace be upon the inhabitants of this city (graveyard) from among the Believers and the Muslims, and may Allah have mercy on those who have gone ahead of us, and those who come later on, and we shall, God willing, join you.