There will be a day of Judgement at the end of the world, when the dead will be
resurrected and judged.

All will be rewarded according to the deeds done in their life. If the good deeds outweigh the bad deeds then they will go to heaven if not then they will go to Hell.

If a Muslim dies in Jihad (Holy War) or on Hajj (Pilgrimage) then they go straight to heaven.