Both zakat and debt should be paid but if there wasn’t enough to do so, debts and zakat should share the same percentage. For example, if a person dies leaving behind only 3,000 in cash but he has a debt of 20,000 and zakat he didn’t pay of 10,000, his heirs must pay 2,000 to the debt and 1,000 to zakat and this means that they will not inherit anything.
It is important to know that when a person dies, his wealth must be spent on the following: first, we have to take what is needed for preparing his funeral rites. Secondly, all his debts must be settled. Thirdly, if he has written a will, his will must be carried out providing that it doesn’t exceed the third of his wealth. Finally, if there is something left, it must be divided by the heirs in accordance to the Quran and Sunnah.