When a person dies in islam, the soul would be taken out of the body and would be in a somewhat purgatory realm or Barzakh until the day of judgement. Its a realm where you wont be able to sense the time. There the souls would be questioned about their beliefs and deeds and would get a small glimpse on what they would go through in the actual afterlife.
Only on the day of judgement, everyone is given back their body and raised from the dead for the final judgement. This is when people get judged and sent to either hell or heaven.
There are a few layes of hell and heaven. Each layer gives different rewards and punishments according to your deeds. Apparently the lowest and worst hell is reserved not for disbelievers but for muslims who are Munafiq. Munafiq is basically those who are muslim but lies, slanders, double crosses and those that are insincere.