Now, in my own words and based on what I know with a summary to the reference further down the page.
When a person dies; their soul is separated from their body. They then stay inside the grave (soul alive) until the Day of Reckoning where they then have to experience the questioning inside the grave "who is your Lord?", "What is your religion?", "Who is your Prophet?" by the two angels, Munkir and Nakir. For those who have sincere imaan, by Allah's mercy, the task of answering these questions is simple. They will respond with "Allah is my Lord", "Islam is my religion" and "Muhammad is my Prophet (saw) who brought the clear proofs from Allah. I believed in him and had faith in him". These are the successful ones. For those among the disbelievers and the hypocrites (those who claimed to be a believer but within their hearts were kafir) are the ones who will not be able to answer the questions and these are the ones who have failed the test and have gained punishment. These will instead respond with "we do not know". Abu-Hurayrah also mentioned this questioning by the angels.
You can also find this situation mentioned inside The Qu'ran and hadith as follows:
Allah keeps firm those who believe, with the firm word, in worldly life and in the Hereafter. And Allah sends astray the wrongdoers. And Allah does what He wills. (Qur'an 14:27)
Those who believe answer the questions easily which they are asked within the grave 'keeps firm those who believe with the firm word' but those who disbelieve fail to answer the questions 'And Allah sends astray the wrongdoers'.
Al-Bukhari and Muslim recorded that Al-Bara bin Azib said that the Messenger of Allah (S.a.W) said, when the Muslim is questioned in the grave, he will testify that 'La ilaha illallah' and that Muhammad is Allah's Messenger (S.a.W), hence Allah's statement, Allah will keep firm those who believe, with word that stands firm in this world, and in the Hereafter.
This is proof that when a person dies, regardless of faith; we will remain in our grave until the Day of Reckoning. But it's also proof (see Qur'an 14:27 above) that those who answered the questions correctly (those with true imaan) are the ones who are among the successful and the ones who can't answer the questions (from amongst the hypocrites* and disbelievers) are the ones that have failed the test; they have astrayed. However Allah through His mercy is able to bestow mercy and forgive whomsoever He wills. Another point to note is that the minor hypocrites* amongst the believers will eventually enter Paradise (as all Muslims will). The major hypocrites however will have an eternal abode in the lowest depths of hell.
May Allah bestow His mercy upon us and make us from amongst the successful whilst protecting us against His punishment even for a second and from hypocrisy. Ameen.
And Allah knows best