The final and complete judgment of a person will take place on the day of Qiyaamah after which complete reward and punishment will be given. However, some actions are such that a portion of their reward or punishment is given in the world, while other actions are such that a portion of their recompense is given in the grave. This in reality is the punishment or reward in the grave.
There are, however, some servants of Allah whom Allah wants to cleanse of their sins. Thus, he punishes them in the grave or even in the world through difficulties so that in the Aakhirah they will not have to go through any difficulties. (Aap ke Masaail vol.1 pg.305)
and Allah Ta’ala Knows Best
Mufti Ebrahim Desai