Praise be to Allaah.
What you refer to in your question is mentioned in two similar aayaat in the Qur’aan. The first of them is the aayah (interpretation of the meaning): “Verily, those who believe and those who are Jews and Christians, and Sabians, whoever believes in Allaah and the Last Day and do righteous good deeds shall have their reward with their Lord, on them shall be no fear, nor shall they grieve.” [al-Baqarah 2:62]
The second is the aayah (interpretation of the meaning): “Surely, those who believe, those who are the Jews and the Sabians and the Christians – whosoever believed in Allaah and the Last Day, and worked righteousness, on them shall be no fear, nor shall they grieve.” [al-Maa’idah 5:69]
In order to understand these aayaat correctly, we need to refer to the scholars of Tafseer (Qur’aanic commentary). The great Imaam Ismaa’eel ibn Katheer, may Allaah have mercy on him, said in his tafseer of the aayah from Soorat al-Baqarah:
“Allaah, may He be exalted, points out that whoever of the previous nations did well and was obedient, will have a good reward, and this will be the case for everyone who follows the Unlettered Prophet [Prophet Muhammad (peace and blessings of Allaah be upon him) until the Hour comes – he will have eternal happiness, and they will not fear what they are going to face, nor will they grieve for what they have left behind. As Allaah says (interpretation of the meaning): ‘No doubt! Verily, the awliya’ of Allaah [i.e., those who believe in the Oneness of Allaah and fear Allaah much, and love Allaah much], no fear shall come upon them nor shall they grieve.’ [Yoonus 10:62]. And Allaah tells us what the angels say to the believers at the time of death (interpretation of the meaning): ‘Verily, those who say, “Our Lord is Allaah,” then they istaqaamu [stood straight, i.e., truly followed Islam], on them the angels will descend (at the time of their death) (saying): “Fear not, nor grieve! But receive the glad tidings of Paradise which you have been promised!”’ [Fussilat 41:30]
As far as the Jews are concerning, their faith meant believing in the Tawraat (original Torah) and following the way of Moosa (peace be upon him) until ‘Eesa came, after which whoever continued to follow the Torah and the way of Moosa, and did not leave this and follow ‘Eesa, was doomed. As far as the Christians are concerned, their faith meant believing in the Injeel (original Gospel) and following the laws of ‘Eesa; whoever did this was a believer whose faith was acceptable to Allaah, until Muhammad (peace and blessings of Allaah be upon him) came, after which whoever did not follow Muhammad (peace and blessings of Allaah be upon him) and leave the way of ‘Eesa and the Injeel that he had been following before, was doomed.
The aayah (interpretation of the meaning), “And whoever seeks a religion other than Islam, it will never be accepted of him, and in the Hereafter he will be one of the losers” [Aal ‘Imraan 3:85] is a statement that Allaah will not accept any way or deed from anyone, after sending His Final Messenger, except those that are in accordance with the laws of Muhammad (peace and blessings of Allaah be upon him). Prior to this, however, anyone who followed the Prophet of his own time was on the Straight Path of salvation. So the Jews were those who followed Moosa (peace be upon him) and referred to the Tawraat for judgement at that time. When Allaah sent ‘Eesa (peace be upon him), the Children of Israel were obliged to follow him and obey him, and so they and others who followed him became Christians.. When Allaah sent Muhammad (peace and blessings of Allaah be upon him), as the Final Prophet and a Messenger to all the children of Adam, all of mankind was obliged to believe in him and obey him, and refrain from what he prohibited. Those who did so are the true believers. The ummah (nation) of Muhammad (peace and blessings of Allaah be upon him) are called the believers because of their deep eemaan (faith) and conviction, and because they believe in all the past Prophets and in the prophesied events that are yet to come.”
Commenting on the aayah in Soorat al-Baqarah, Ibn Katheer (may Allaah have mercy on him) said:
“What is meant is that every group believed in Allaah and the Last Day, which is the appointed Day of Reckoning, and did righteous deeds. But after Muhammad (peace and blessings of Allaah be upon him) was sent to both mankind and the jinn, true belief can only be in accordance with the way of Muhammad (peace and blessings of Allaah be upon him). Whoever follows his way will not fear the future or grieve for what they leave behind.