Greeting with the Salam is a Sign of Islam
Allah says;
يَا أَيُّهَا الَّذِينَ امَنُواْ إِذَا ضَرَبْتُمْ فِي سَبِيلِ اللّهِ فَتَبَيَّنُواْ وَلَا تَقُولُواْ لِمَنْ أَلْقَى إِلَيْكُمُ السَّلَمَ لَسْتَ مُوْمِنًا تَبْتَغُونَ عَرَضَ الْحَيَاةِ الدُّنْيَا
O you who believe! When you go (to fight) in the cause of Allah, verify (the truth), and say not to anyone who greets you;"You are not a believer;" seeking the perishable goods of the worldly life.
Imam Ahmad recorded that Ikrimah said that Ibn Abbas said,
"A man from Bani Sulaym, who was tending a flock of sheep, passed by some of the Companions of the Prophet and said Salam to them. They said (to each other), `He only said Salam to protect himself from us.' Then they attacked him and killed him. They brought his sheep to the Prophet, and this Ayah was revealed,
يَا أَيُّهَا الَّذِينَ امَنُواْ
(O you who believe!), until the end of the Ayah."
At-Tirmidhi recorded this in his (chapter on) Tafsir, and said, "This Hadith is Hasan, and it is also reported from Usamah bin Zayd."
Al-Hakim also recorded it and said, "Its chain is Sahih, but they did not collect it."
Al-Bukhari recorded that Ibn Abbas commented;
وَلَا تَقُولُواْ لِمَنْ أَلْقَى إِلَيْكُمُ السَّلَمَ لَسْتَ مُوْمِنًا
(and say not to anyone who greets you;"You are not a believer),"
"A man was tending his sheep and the Muslims caught up with him. He said, `As-Salamu Alaykum.' However, they killed him and took his sheep. Allah revealed the Ayah;
وَلَا تَقُولُواْ لِمَنْ أَلْقَى إِلَيْكُمُ السَّلَمَ لَسْتَ مُوْمِنًا تَبْتَغُونَ عَرَضَ الْحَيَاةِ الدُّنْيَا
(And say not to anyone who greets you;"You are not a believer; seeking the perishable goods of the worldly life)."
Ibn Abbas said; "The goods of this world were those sheep." And he recited,
السَّلَمَ
(Peace)."
Imam Ahmad recorded that Al-Qa`qa bin Abdullah bin Abi Hadrad narrated that his father Abdullah bin Abi Hadrad said,
"The Messenger of Allah sent us to (the area of) Idam. I rode out with a group of Muslims that included Abu Qatadah, Al-Harith bin Rabi and Muhallam bin Juthamah bin Qays. We continued on until we reached the area of Idam, where `Amr bin Al-Adbat Al-Ashja`i passed by us on his camel. When he passed by us he said Salam to us, and we did not attack him. Because of some previous problems with him, Muhallam bin Juthamah killed him and took his camel. When we went back to the Messenger of Allah and told him what had happened, a part of the Qur'an was revealed about us,
يَا أَيُّهَا الَّذِينَ امَنُواْ إِذَا ضَرَبْتُمْ فِي سَبِيلِ اللّهِ
(O you who believe! When you go (to fight) in the cause of Allah), until,
خَبِيرًا
(Well-Aware)." Only Ahmad recorded this Hadith.
Al-Bukhari recorded that Ibn Abbas said that the Messenger of Allah said to Al-Miqdad,
إِذَا كَانَ رَجُلٌ مُوْمِنٌ يُخْفِي إِيمَانَهُ مَعَ قَوْمٍ كُفَّارٍ فَأَظْهَرَ إيمَانَهُ فَقَتَلْتَهُ فَكَذلِكَ كُنْتَ أَنْتَ تُخْفِي إِيمَانَكَ بِمَكَّةَ مِنْ قَبْل
You killed a believing man who hid his faith with disbelieving people, after he had announced his faith to you. Remember that you used to hide your faith in Makkah before.
Al-Bukhari recorded this shorter version without a complete chain of narrators.
However a longer version with a connected chain of narrators has also been recorded.
Al-Hafiz Abu Bakr Al-Bazzar recorded that Ibn Abbas said,
"The Messenger of Allah sent a military expedition under the authority of Al-Miqdad bin Al-Aswad and when they reached the designated area, they found the people had dispersed.
However, a man with a lot of wealth did not leave and said, `I bear witness that there is no deity worthy of worship except Allah.'
Yet, Al-Miqdad killed him, and a man said to him, `You killed a man after he proclaimed;`There is no deity worthy of worship except Allah. By Allah I will mention what you did to the Prophet.'
When they went back to the Messenger of Allah, they said, `O Messenger of Allah! Al-Miqdad killed a man who testified that there is no deity worthy of worship except Allah.'
He said,
ادْعُوا لِيَ الْمِقْدَادَ يَا مِقْدَادُ أَقَتَلْتَ رَجُلً يَقُولُ لَا إِلهَ إلاَّ اللهُ فَكَيْفَ لَكَ بِلَ إِلهَ إِلاَّ اللهُ غَدًا
Summon Al-Miqdad before me. O Miqdad! Did you kill a man who proclaimed, "There is no deity worthy of worship except Allah." What would you do when you face, "There is no deity worthy of worship except Allah tomorrow!"
Allah then revealed;
يَا أَيُّهَا الَّذِينَ امَنُواْ إِذَا ضَرَبْتُمْ فِي سَبِيلِ اللّهِ فَتَبَيَّنُواْ وَلَا تَقُولُواْ لِمَنْ أَلْقَى إِلَيْكُمُ السَّلَمَ لَسْتَ مُوْمِنًا تَبْتَغُونَ عَرَضَ الْحَيَاةِ الدُّنْيَا فَعِندَ اللّهِ مَغَانِمُ كَثِيرَةٌ كَذَلِكَ كُنتُم مِّن قَبْلُ فَمَنَّ اللّهُ عَلَيْكُمْ فَتَبَيَّنُواْ
O you who believe! When you go (to fight) in the cause of Allah, verify (the truth), and say not to anyone who greets you;"You are not a believer;" seeking the perishable goods of the worldly life. There are much more profits and booties with Allah. Even as he is now, so were you yourselves before till Allah conferred on you His Favors, therefore, be cautious in discrimination.
The Messenger of Allah said to Al-Miqdad,
كَانَ رَجُلٌ مُوْمِنٌ يُخْفِي إِيمَانَهُ مَعَ قَوْمٍ كُفَّارٍ فَأَظْهَرَ إيمَانَهُ فَقَتَلْتَهُ فَكَذَلِكَ كُنْتَ أَنْتَ تُخْفِي إِيمَانَكَ بِمَكَّةَ مِنْ قَبْل
He was a believing man who hid his faith among disbelieving people, and he announced his faith to you, but you killed him, although you used to hide your faith before, in Makkah."
Allah's statement,
فَعِندَ اللّهِ مَغَانِمُ كَثِيرَةٌ
There is much more benefit with Allah.
means, better than what you desired of worldly possessions which made you kill the one who greeted you with the Salam and pronounced his faith to you. Yet, you ignored all this and accused him of hypocrisy, to acquire the gains of this life. However, the pure wealth with Allah is far better than what you acquired.
Allah's statement,
كَذَلِكَ
كُنتُم مِّن قَبْلُ فَمَنَّ اللّهُ عَلَيْكُمْ
so were you yourselves before, till Allah conferred on you His Favors.
means, beforehand, you used to be in the same situation like this person who hid his faith from his people.
We mentioned the relevant Hadiths above. Allah said,
وَاذْكُرُواْ إِذْ أَنتُمْ قَلِيلٌ مُّسْتَضْعَفُونَ فِى الاٌّرْضِ
And remember when you were few and were reckoned weak in the land. (8;26)
Abdur-Razzaq recorded that Sa`id bin Jubayr commented about Allah's statement,
كَذَلِكَ
كُنتُم مِّن قَبْلُ
(so were you yourselves before),
"You used to hide your faith, just as this shepherd hid his faith."
Allah said,
فَتَبَيَّنُواْ
therefore, be cautious in discrimination,
then said,
إِنَّ اللّهَ كَانَ بِمَا تَعْمَلُونَ خَبِيرًا
Allah is Ever Well-Aware of what you do.
and this part of the Ayah contains a threat and a warning, as Sa`id bin Jubayr stated