As for the trial in the graves, it is the examination and testing of the deceased when the two angels question him, asking:
“What did you used to say about this man who was sent among you—Muhammad?”
Allah makes those who believe steadfast with the firm word, so the believer says:
“Allah is my Lord, Islam is my religion, and Muhammad is my Prophet.”
He also says:
“He is Muhammad, the Messenger of Allah. He came to us with clear proofs and guidance, so we believed in him and followed him.”
The two angels then sternly rebuke him—this being the last of the trials to which the believer is subjected—and repeat their original question.
Hadiths concerning this trial have been mass-transmitted from the Prophet (peace and blessings be upon him), through the reports of al-Barā’ ibn Āzib, Anas ibn Mālik, Abū Hurayrah, and others (may Allah be pleased with them). This trial applies to all those subject to religious obligations, except that scholars have differed concerning the prophets. They have likewise differed concerning those not subject to religious obligations, such as children and the insane.
One view is that they are not subjected to this trial, because such testing concerns only those subject to religious obligations. This is the view of al-Qādī and Ibn Aqīl. According to this view, they are not prompted with the answers after death.
Another view is that they are prompted and are also subjected to the trial. This is the view of Abū Hakīm and Abū al-Hasan ibn Abdūs, who also reported it from his fellow scholars. It accords with the view that they will be charged with obligations on the Day of Resurrection, which is the position of most scholars and of most of Ahl al-Sunnah among hadith scholars and theologians. This is the position that Abū al-Hasan al-Asharī (may Allah be pleased with him) reported from Ahl al-Sunnah and adopted himself, and it is what Imam Ahmad’s explicit statements imply.
As for “apostasy from Islam,” whereby a man becomes a disbeliever—either a polytheist or one of the People of the Book—