Praise be to Allah.
Difference of religion is one of the factors which prevent inheritance. A kaafir cannot inherit from a Muslim, according to scholarly consensus, and a Muslim cannot inherit from a kaafir, because the Prophet (peace and blessings of Allaah be upon him) said: A Muslim does not inherit from a kaafir and a kaafir does not inherit from a Muslim. (Reported by al-Bukhaari, 6262).
If a kaafir becomes Muslim before the legacy is shared out, then according to Imaam Ahmad he is allowed to inherit, to encourage him in his Islam. As regards the kuffaar inheriting from one another, according to Imaam Abu Haneefah and Imaam al-Shaafa'i, and according to one opinion narrated from Ahmad, they can inherit from one another even if they belong to different religions, because Allaah says (interpretation of the meaning): And those who disbelieve are allies to one another [al-Anfaal 8:73], and because despite the differences in their religions and sects, they are as one in their enmity towards the Muslims.