Will the one whose good deeds outweigh his bad deeds in the Balance be punished in his grave?
Question

                I understand and realize that the Muslim may be punished in the grave, but what I want to know is the following: we know that the Muslim’s deeds will be weighed on the Day of Resurrection, and if his good deeds outweigh his bad deeds, then Allah, may He be glorified and exalted, will forgive this Muslim man or woman and admit him or her to Paradise. My question is: when this particular Muslim is in his grave, will he be punished in his grave even though Allah, may He be glorified and exalted, will forgive him on the Day of Resurrection? Will we be punished in the hereafter even though we are going to enter Paradise?
Praise be to Allah.Firstly:
Ahl as-Sunnah wa’l-Jamaa‘ah believe in the punishment and bliss in the grave, as proven in the sound religious texts, as is indicated by the verses of the Qur’an, the hadiths of the Prophet (blessings and peace of Allah be upon him) and as is agreed upon by the salaf or early generations of this ummah.
This has been discussed in the answer to question no. 34648.
In the answer to question no. 47055, you will find that the basic principle concerning punishment and bliss in the grave is that they will happen to the soul, and the soul may be connected to the body, in which case some of that punishment or bliss will be felt physically.
In the answers to questions no. 7862 and 21212, we explained that the punishment of the grave will, in some cases, last until the onset of the Hour, and in other cases it will cease before that.
Secondly:
It should be noted that the fact that good deeds outweigh bad deeds will not necessarily save a person from punishment in the grave, because the reason for the warning that some deeds may lead to punishment in al-barzakh is not the same as the reason for the warning that some deeds may lead to punishment in the fire of Hell. The Muslim may have one of the reasons that could lead to punishment in the grave, so he will be punished for that, but he may also have good deeds like mountains.
With regard to the Balance in which people’s deeds will be weighed, after which some groups will be doomed because their good deeds are outweighed by bad deeds, and others will be blessed because their good deeds weigh heavily in the balance, that will only happen towards the end of the Day of Judgement, after the people have gone through many stages of the hereafter.
Abu ‘Abdillah al-Qurtubi (may Allah have mercy on him) said:
What is indicated by the verses and reports is that the one whose good deeds weigh heavily in the balance will be saved and will be certain of Paradise, and he will know that he will not enter the Fire after that. And Allah knows best.
At-Tadhkirah fi Ahwaal al-Mawtaa wa Umoor al-Aakhirah (p. 272).
If we assume that there is a Muslim who has so many good deeds to his credit that if they were to be weighed directly after his death they would weigh heavily, still he will not be saved from the punishment in the grave if Allah wishes to punish him for some of those bad deeds. Let the questioner reflect upon the following scenarios, which will resolve this confusion in his mind:
1.
A person whose good deeds outweigh his bad deeds, and he correctly answers the questions of the two angels in the grave. That does not necessarily mean that he will be spared the punishment in the grave, if he did bad deeds for which he deserves that punishment, and if Allah wills that he should be punished for that in his grave.
2.
A person whose good deeds outweigh his bad deeds: when he sees his place in Paradise in his grave, that does not mean that he will not be punished for whatever Allah wills of his sins. There are two scholarly views concerning this:

if someone committed bad deeds and Allah wishes to punish him in the grave, but in the hereafter he will be one of the people of Paradise, he will be shown his place in Paradise on the basis that it is his ultimate destination;
he may be shown his place in Hell because of his current situation (in which he deserves punishment in the grave, but that is not his ultimate destination).

See also the answer to question no. 121628.
Based on that:
if a person’s good deeds outweigh his bad deeds, that does not mean that he will not be punished in his grave for some sins concerning which there is the warning that the one who does them will be punished in his grave, such as the punishment for dealing in riba, which is swimming in a river of blood; the punishment for men and women who commit zina; the punishment for spreading malicious gossip, stealing from the war booty, lying, not making sure to clean oneself probably after urinating, and other cases in which the texts clearly mention some sins in particular.
For more details, please see the answers to questions no. 46068 and 45325.
Thirdly:
In His wisdom, Allah, may He be exalted, does not weigh deeds in the balance as soon as a person dies. It seems to us that there are several reasons for that:
1.
The sinner’s burden of bad deeds will be reduced by means of punishment in the grave, which will reduce punishment in Hell for him. Undoubtedly what will befall a person of punishment in the grave is easier for him to bear than what would befall him in the Fire of Hell.
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
What befalls a believer in this world, in al-barzakh and on the Day of Resurrection of pain and suffering, which is punishment, is a means by which Allah expiates his sins, as it is proven in as-Saheehayn that the Prophet (blessings and peace of Allah be upon him) said: “No tiredness, exhaustion, grief or befalls a believer, not even a thorn that pricks him, but Allah expiates some of his sins thereby.”
Majmoo‘ al-Fataawa (24/375).
He (may Allah have mercy on him) said:
…the eighth reason: what will happen in the grave of trials, squeezing and terror; these are things that expiate sins.
Majmoo‘ al-Fataawa (7/500).
See also the answer to question no. 7861.
2.
Not everyone who does good deeds will find that they remain with him until he enters Paradise because of them, and not everyone who does bad deeds will find that they remain with him until he enters Hell because of them. There is something called “settling scores”, which is when those who have rights will take from the good deeds of those who wronged them, or their bad deeds will be cast onto them, as mentioned in the hadith about the one who is bankrupt*, which was narrated by Imam Muslim in his Saheeh. This will happen before deeds are weighed in the Balance.
[*the Prophet (peace and blessings of Allah be upon him) said to his companions one day:  “Do you know who is the one who is bankrupt?” They said: “Among us, the one who is bankrupt is the one who has no dirhams and no goods.” He said: “Rather the one who is bankrupt amongst my ummah is the one who will come on the Day of Resurrection with prayer, fasting and zakaah, but he will come having insulted this one, slandered that one, consumed the wealth of this one, shed the blood of that one and beaten this one, all of whom will be given some of his hasanaat (good deeds), and if his hasanaat run out before the scores have been settled, some of their sins will be taken and thrown onto him, then he will be cast into the Fire.”]
Abu ‘Abdillah al-Qurtubi (may Allah have mercy on him) said:
As for those whose deeds are mixed, their good deeds will be placed in the bright pan and their bad deeds will be placed in the dark pan, and their major sins will have weight. If their good deeds weigh more heavily, even by as much as a nit – which is the egg of a louse – he will enter Paradise; if their bad deeds weigh more heavily, even by as much as a nit, he will enter Hell, unless Allah forgives him. If his bad deeds and good deeds are equal, he will be one of the people of the a‘raaf [a place between Paradise and Hell]. This applies if his major sins concern matters that are between him and Allah. But if he owes anything to other people, and he has many good deeds, his good deeds will be taken from him and given to those he owes, commensurate with what he owes; if he runs out of good deeds because he owes too much, then he will be given some of the burden of sin of those whom he wronged, then he will be punished for all of that, as is indicated in the reports.
At-Tadhkirah fi Ahwaal al-Mawtaa wa Umoor al-Aakhirah (p. 269, 270).
3.
Good deeds and bad deeds do not cease after death; rather there are ongoing good deeds and ongoing bad deeds. The former includes one who gives ongoing charity, or teaches beneficial knowledge, or guides someone else to do a righteous deed, or he has children who do righteous deeds after he dies; all of these offer the deceased the chance to increase his good deeds. The latter includes one who tells someone else to do a bad deed, or introduces an innovation, and other cases in which bad deeds are incurred by the doer and the deceased who was the cause of others doing those bad deeds and innovations.
Thus it is known that the counter of good deeds and bad deeds does not stop when someone dies. Hence we see great wisdom in not using the balance when the Muslim first dies. Rather the balance will come only at the end of the events of the Day of Resurrection, and after that people will be admitted to Paradise or Hell. At that point, the Muslim will understand the meaning of the verses in which Allah, may He be exalted, says (interpretation of the meaning):
“And the weighing [of deeds] that Day will be the truth. So those whose scales are heavy - it is they who will be the successful”
[al-A‘raaf 7:8]
“Then as for one whose scales are heavy [with good deeds],
He will be in a pleasant life”
[al-Qaari‘ah 101:6-7].
And Allah knows best.